aboutsummaryrefslogtreecommitdiff
path: root/telegram/handlers.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2023-07-22 17:46:35 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2023-07-22 17:46:35 +0300
commit748366ad6a9dc4b2a269d5499ae1d5d7e8526762 (patch)
tree11af2e901a14cd9483abbd4e30a2ce024ad8488f /telegram/handlers.go
parenteadef987be11dc22a89c2aad990814bd89add770 (diff)
Avoid webpage preview updates being sent as message edits (by hash matching)
Diffstat (limited to 'telegram/handlers.go')
-rw-r--r--telegram/handlers.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/telegram/handlers.go b/telegram/handlers.go
index abc1f5d..cc6e635 100644
--- a/telegram/handlers.go
+++ b/telegram/handlers.go
@@ -226,6 +226,8 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
}).Warn("New message from chat")
c.ProcessIncomingMessage(chatId, update.Message, ignoredResource)
+
+ c.updateLastMessageHash(update.Message.ChatId, update.Message.Id, update.Message.Content)
}()
}
@@ -233,6 +235,8 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
func (c *Client) updateMessageContent(update *client.UpdateMessageContent) {
markupFunction := formatter.EntityToXEP0393
+ defer c.updateLastMessageHash(update.ChatId, update.MessageId, update.NewContent)
+
c.SendMessageLock.Lock()
c.SendMessageLock.Unlock()
xmppId, err := gateway.IdsDB.GetByTgIds(c.Session.Login, c.jid, update.ChatId, update.MessageId)
@@ -250,7 +254,7 @@ func (c *Client) updateMessageContent(update *client.UpdateMessageContent) {
return
}
- if update.NewContent.MessageContentType() == client.TypeMessageText {
+ if update.NewContent.MessageContentType() == client.TypeMessageText && c.hasLastMessageHashChanged(update.ChatId, update.MessageId, update.NewContent) {
textContent := update.NewContent.(*client.MessageText)
var editChar string
if c.Session.AsciiArrows {