Send unavailable status to cached chats on disconnect
This commit is contained in:
parent
8cd6387552
commit
c22008d991
|
@ -3,6 +3,7 @@ package telegram
|
|||
import (
|
||||
"github.com/pkg/errors"
|
||||
"math"
|
||||
"strconv"
|
||||
|
||||
"dev.narayana.im/narayana/telegabber/xmpp/gateway"
|
||||
|
||||
|
@ -122,13 +123,22 @@ func (c *Client) Connect() error {
|
|||
|
||||
// Disconnect drops TDlib connection
|
||||
func (c *Client) Disconnect() {
|
||||
// already disconnected
|
||||
if !c.online {
|
||||
return
|
||||
}
|
||||
|
||||
log.Warn("Disconnecting from Telegram network...")
|
||||
|
||||
// TODO: send unavailable presence to cached chats
|
||||
// we're offline (unsubscribe if logout)
|
||||
for id := range c.cache.chats {
|
||||
gateway.SendPresence(
|
||||
c.xmpp,
|
||||
c.jid,
|
||||
gateway.SPFrom(strconv.FormatInt(id, 10)),
|
||||
gateway.SPType("unavailable"),
|
||||
)
|
||||
}
|
||||
|
||||
c.client.Destroy()
|
||||
c.online = false
|
||||
|
|
Loading…
Reference in a new issue