aboutsummaryrefslogtreecommitdiff
path: root/telegram/client.go
diff options
context:
space:
mode:
authorbodqhrohro <bodqhrohro@gmail.com>2019-12-05 00:47:44 +0300
committerbodqhrohro <bodqhrohro@gmail.com>2019-12-05 00:47:44 +0300
commit8cd6387552dc9b73c60950e8c1a47c84ae13f98b (patch)
treeb3ea81add8cbac8fee2a5153f792cdf217a65d10 /telegram/client.go
parentfa841bfa8bc0941e0416608e78308401c9334ae9 (diff)
Make chats/users cache private
Diffstat (limited to 'telegram/client.go')
-rw-r--r--telegram/client.go22
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: &parameters,
- xmpp: component,
- jid: jid,
- Session: session,
- content: &conf.Content,
+ parameters: &parameters,
+ 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