diff options
Diffstat (limited to 'telegram/utils.go')
-rw-r--r-- | telegram/utils.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/telegram/utils.go b/telegram/utils.go index 865c4d4..641f6d6 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -580,3 +580,37 @@ func (c *Client) ProcessOutgoingMessage(chatID int64, text string, messageID int func (c *Client) StatusesRange() chan *cache.Status { return c.cache.StatusesRange() } + +func (c *Client) addResource(resource string) { + if resource == "" { + return + } + c.locks.resourcesLock.Lock() + defer c.locks.resourcesLock.Unlock() + + c.resources[resource] = true +} + +func (c *Client) deleteResource(resource string) { + c.locks.resourcesLock.Lock() + defer c.locks.resourcesLock.Unlock() + + if _, ok := c.resources[resource]; ok { + delete(c.resources, resource) + } +} + +// refresh roster +func (c *Client) refresh(resource string) { + if _, ok := c.resources[resource]; ok { + return + } + + log.Warnf("Refreshing roster for resource %v", resource) + + for _, chat := range c.cache.ChatsKeys() { + c.ProcessStatusUpdate(chat, "", "") + } + + c.addResource(resource) +} |