diff options
author | bodqhrohro <bodqhrohro@gmail.com> | 2019-12-05 00:47:44 +0300 |
---|---|---|
committer | bodqhrohro <bodqhrohro@gmail.com> | 2019-12-05 00:47:44 +0300 |
commit | 8cd6387552dc9b73c60950e8c1a47c84ae13f98b (patch) | |
tree | b3ea81add8cbac8fee2a5153f792cdf217a65d10 /telegram/client.go | |
parent | fa841bfa8bc0941e0416608e78308401c9334ae9 (diff) |
Make chats/users cache private
Diffstat (limited to 'telegram/client.go')
-rw-r--r-- | telegram/client.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/telegram/client.go b/telegram/client.go index a7fe332..f15d07d 100644 --- a/telegram/client.go +++ b/telegram/client.go @@ -23,16 +23,11 @@ var logConstants = map[string]int32{ ":all": 1023, } -type cacheStruct struct { +type cache struct { chats map[int64]*client.Chat users map[int32]*client.User } -var cache = cacheStruct{ - chats: map[int64]*client.Chat{}, - users: map[int32]*client.User{}, -} - func stringToLogConstant(c string) int32 { level, ok := logConstants[c] if !ok { @@ -54,6 +49,7 @@ type Client struct { jid string Session *persistence.Session content *config.TelegramContentConfig + cache *cache locks clientLocks online bool @@ -98,11 +94,15 @@ func NewClient(conf config.TelegramConfig, jid string, component *xmpp.Component } return &Client{ - parameters: ¶meters, - xmpp: component, - jid: jid, - Session: session, - content: &conf.Content, + parameters: ¶meters, + xmpp: component, + jid: jid, + Session: session, + content: &conf.Content, + cache: &cache{ + chats: map[int64]*client.Chat{}, + users: map[int32]*client.User{}, + }, logVerbosity: logVerbosity, locks: clientLocks{}, }, nil |