aboutsummaryrefslogtreecommitdiff
path: root/telegram/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'telegram/client.go')
-rw-r--r--telegram/client.go25
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,