aboutsummaryrefslogtreecommitdiff
path: root/telegram/client.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-01-31 17:31:05 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-01-31 17:31:05 +0300
commit3cdb625c5edb90ad6c55bacc2daea51385952750 (patch)
treeea65e10369eda6583b9508094ffe421f548b8062 /telegram/client.go
parent8c20aaa30d2ca7483e56c2a3cb95e83a051013ea (diff)
Mark expired online statuses as away
Diffstat (limited to 'telegram/client.go')
-rw-r--r--telegram/client.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/telegram/client.go b/telegram/client.go
index 8813df0..5220c2d 100644
--- a/telegram/client.go
+++ b/telegram/client.go
@@ -34,6 +34,12 @@ func stringToLogConstant(c string) int32 {
return level
}
+// DelayedStatus describes an online status expiring on timeout
+type DelayedStatus struct {
+ TimestampOnline int64
+ TimestampExpired int64
+}
+
// Client stores the metadata for lazily invoked TDlib instance
type Client struct {
client *client.Client
@@ -50,6 +56,9 @@ type Client struct {
cache *cache.Cache
online bool
+ DelayedStatuses map[int64]*DelayedStatus
+ DelayedStatusesLock sync.Mutex
+
locks clientLocks
}
@@ -115,6 +124,7 @@ func NewClient(conf config.TelegramConfig, jid string, component *xmpp.Component
content: &conf.Content,
cache: cache.NewCache(),
options: options,
+ DelayedStatuses: make(map[int64]*DelayedStatus),
locks: clientLocks{
chatMessageLocks: make(map[int64]*sync.Mutex),
},