aboutsummaryrefslogtreecommitdiff
path: root/telegram/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'telegram/client.go')
-rw-r--r--telegram/client.go17
1 files changed, 5 insertions, 12 deletions
diff --git a/telegram/client.go b/telegram/client.go
index 2acd75e..dde15f2 100644
--- a/telegram/client.go
+++ b/telegram/client.go
@@ -9,6 +9,7 @@ import (
"dev.narayana.im/narayana/telegabber/config"
"dev.narayana.im/narayana/telegabber/persistence"
+ "dev.narayana.im/narayana/telegabber/telegram/cache"
"github.com/zelenin/go-tdlib/client"
"gosrc.io/xmpp"
@@ -24,11 +25,6 @@ var logConstants = map[string]int32{
":all": 1023,
}
-type cache struct {
- chats map[int64]*client.Chat
- users map[int32]*client.User
-}
-
func stringToLogConstant(c string) int32 {
level, ok := logConstants[c]
if !ok {
@@ -51,7 +47,7 @@ type Client struct {
jid string
Session *persistence.Session
content *config.TelegramContentConfig
- cache *cache
+ cache *cache.Cache
online bool
locks clientLocks
@@ -109,11 +105,8 @@ func NewClient(conf config.TelegramConfig, jid string, component *xmpp.Component
jid: jid,
Session: session,
content: &conf.Content,
- cache: &cache{
- chats: map[int64]*client.Chat{},
- users: map[int32]*client.User{},
- },
- options: options,
- locks: clientLocks{},
+ cache: cache.NewCache(),
+ options: options,
+ locks: clientLocks{},
}, nil
}