diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-01-06 00:04:22 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-01-06 00:04:22 +0300 |
commit | 077edae986f2229d263f978b7cf35ed88254c042 (patch) | |
tree | 01877034c1989565e2de30bce04d1c15eb06579e /telegram/utils.go | |
parent | d48cb8b58682d3b9c5798913de35ae62dd20dd38 (diff) |
Add keeponline option
Diffstat (limited to 'telegram/utils.go')
-rw-r--r-- | telegram/utils.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/telegram/utils.go b/telegram/utils.go index cdd2914..4c73f9e 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -48,7 +48,7 @@ func (c *Client) GetContactByUsername(username string) (*client.Chat, *client.Us // GetContactByID gets user and chat information from cache (or tries to retrieve it, if missing) func (c *Client) GetContactByID(id int64, chat *client.Chat) (*client.Chat, *client.User, error) { - if !c.Online() { + if !c.Online() || id == 0 { return nil, nil, errOffline } @@ -600,17 +600,19 @@ func (c *Client) deleteResource(resource string) { } } -// refresh roster -func (c *Client) refresh(resource string) { +// resend statuses to (to another resource, for example) +func (c *Client) roster(resource string) { if _, ok := c.resources[resource]; ok { - return + return // we know it } - log.Warnf("Refreshing roster for resource %v", resource) + log.Warnf("Sending roster for %v", resource) for _, chat := range c.cache.ChatsKeys() { c.ProcessStatusUpdate(chat, "", "") } + gateway.SendPresence(c.xmpp, c.jid, gateway.SPStatus("Logged in as: "+c.Session.Login)) + c.addResource(resource) } |