diff options
Diffstat (limited to 'xmpp/handlers.go')
-rw-r--r-- | xmpp/handlers.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/xmpp/handlers.go b/xmpp/handlers.go index f7f628b..2addd7b 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -148,6 +148,7 @@ func handlePresence(s xmpp.Sender, p stanza.Presence) { }).Warn("Presence") log.Debugf("%#v", p) + // create session fromJid, err := xmpp.NewJid(p.From) if err != nil { log.Error("Invalid from JID!") @@ -160,11 +161,14 @@ func handlePresence(s xmpp.Sender, p stanza.Presence) { } switch p.Type { + // destroy session case "unsubscribed", "unsubscribe": session.Disconnect() delete(sessions, bareFromJid) + // go offline case "unavailable", "error": session.Disconnect() + // go online case "probe", "", "online": // due to the weird implementation of go-tdlib wrapper, it won't // return the client instance until successful authorization |