diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2023-08-26 15:59:14 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2023-08-26 15:59:14 +0300 |
commit | 8ba7596ab5b9cd731fb507f60da51c6acf1ef27f (patch) | |
tree | 91e17a6bdd70300f2d784e60a1f88d47d3ec18ad /telegram/handlers.go | |
parent | 3c917c16983c1afdd4a21d8021461585a1e785c9 (diff) | |
parent | 64515e2c666067953e3a9680b4f0db84f3838498 (diff) |
Merge branch 'master' into dev
Diffstat (limited to 'telegram/handlers.go')
-rw-r--r-- | telegram/handlers.go | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/telegram/handlers.go b/telegram/handlers.go index cedea63..0d1cda9 100644 --- a/telegram/handlers.go +++ b/telegram/handlers.go @@ -205,27 +205,24 @@ func (c *Client) updateChatLastMessage(update *client.UpdateChatLastMessage) { func (c *Client) updateNewMessage(update *client.UpdateNewMessage) { chatId := update.Message.ChatId - c.SendMessageLock.Lock() - c.SendMessageLock.Unlock() - xmppId, err := gateway.IdsDB.GetByTgIds(c.Session.Login, c.jid, chatId, update.Message.Id) - var ignoredResource string - if err == nil { - ignoredResource = c.popFromOutbox(xmppId) - } else { - log.Infof("Couldn't retrieve XMPP message ids for %v, an echo may happen", update.Message.Id) - } - // guarantee sequential message delivering per chat lock := c.getChatMessageLock(chatId) go func() { lock.Lock() defer lock.Unlock() + // ignore self outgoing messages + if update.Message.IsOutgoing && + update.Message.SendingState != nil && + update.Message.SendingState.MessageSendingStateType() == client.TypeMessageSendingStatePending { + return + } + log.WithFields(log.Fields{ "chat_id": chatId, }).Warn("New message from chat") - c.ProcessIncomingMessage(chatId, update.Message, ignoredResource) + c.ProcessIncomingMessage(chatId, update.Message) c.updateLastMessageHash(update.Message.ChatId, update.Message.Id, update.Message.Content) }() |