diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2023-10-04 01:56:37 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2023-10-04 01:56:37 +0300 |
commit | 1e7e761c6ce7bda3850ed23d0e64d884a28f60a7 (patch) | |
tree | 4db6cc5ffc62ac91f4e662b2546a17fb62621e00 /telegram/client.go | |
parent | b8a57c06b646edbad340c9e1c6c79e11a8a666e3 (diff) |
Reflect name change of Telegram user in all MUCs
Diffstat (limited to 'telegram/client.go')
-rw-r--r-- | telegram/client.go | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/telegram/client.go b/telegram/client.go index 6033c7c..f3bfe4a 100644 --- a/telegram/client.go +++ b/telegram/client.go @@ -41,6 +41,25 @@ type DelayedStatus struct { TimestampExpired int64 } +// MUCState holds MUC metadata +type MUCState struct { + Resources map[string]bool + Members map[int64]*MUCMember +} + +// MUCMember represents a MUC member +type MUCMember struct { + Nickname string + Affiliation string +} + +func NewMUCState() *MUCState { + return &MUCState{ + Resources: make(map[string]bool), + Members: make(map[int64]*MUCMember), + } +} + // Client stores the metadata for lazily invoked TDlib instance type Client struct { client *client.Client @@ -64,7 +83,7 @@ type Client struct { lastMsgHashes map[int64]uint64 msgHashSeed maphash.Seed - mucResources map[int64]map[string]bool + mucCache map[int64]*MUCState locks clientLocks SendMessageLock sync.Mutex @@ -75,7 +94,7 @@ type clientLocks struct { chatMessageLocks map[int64]*sync.Mutex resourcesLock sync.Mutex outboxLock sync.Mutex - mucResourcesLock sync.Mutex + mucCacheLock sync.Mutex lastMsgHashesLock sync.Mutex authorizerReadLock sync.Mutex @@ -136,7 +155,7 @@ func NewClient(conf config.TelegramConfig, jid string, component *xmpp.Component Session: session, resources: make(map[string]bool), outbox: make(map[string]string), - mucResources: make(map[int64]map[string]bool), + mucCache: make(map[int64]*MUCState), content: &conf.Content, cache: cache.NewCache(), options: options, |