diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2023-07-22 17:46:35 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2023-07-22 17:46:35 +0300 |
commit | 748366ad6a9dc4b2a269d5499ae1d5d7e8526762 (patch) | |
tree | 11af2e901a14cd9483abbd4e30a2ce024ad8488f /telegram/client.go | |
parent | eadef987be11dc22a89c2aad990814bd89add770 (diff) |
Avoid webpage preview updates being sent as message edits (by hash matching)
Diffstat (limited to 'telegram/client.go')
-rw-r--r-- | telegram/client.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/telegram/client.go b/telegram/client.go index 61d46aa..5b0217a 100644 --- a/telegram/client.go +++ b/telegram/client.go @@ -2,6 +2,7 @@ package telegram import ( "github.com/pkg/errors" + "hash/maphash" "path/filepath" "strconv" "sync" @@ -60,6 +61,9 @@ type Client struct { DelayedStatuses map[int64]*DelayedStatus DelayedStatusesLock sync.Mutex + lastMsgHashes map[int64]uint64 + msgHashSeed maphash.Seed + locks clientLocks SendMessageLock sync.Mutex } @@ -69,6 +73,7 @@ type clientLocks struct { chatMessageLocks map[int64]*sync.Mutex resourcesLock sync.Mutex outboxLock sync.Mutex + lastMsgHashesLock sync.Mutex } // NewClient instantiates a Telegram App @@ -129,6 +134,8 @@ func NewClient(conf config.TelegramConfig, jid string, component *xmpp.Component cache: cache.NewCache(), options: options, DelayedStatuses: make(map[int64]*DelayedStatus), + lastMsgHashes: make(map[int64]uint64), + msgHashSeed: maphash.MakeSeed(), locks: clientLocks{ chatMessageLocks: make(map[int64]*sync.Mutex), }, |