diff options
Diffstat (limited to 'xmpp')
-rw-r--r-- | xmpp/component.go | 19 | ||||
-rw-r--r-- | xmpp/handlers.go | 2 |
2 files changed, 20 insertions, 1 deletions
diff --git a/xmpp/component.go b/xmpp/component.go index fb5732e..e22b221 100644 --- a/xmpp/component.go +++ b/xmpp/component.go @@ -85,6 +85,25 @@ func heartbeat(component *xmpp.Component) { // status updater thread for { time.Sleep(60e9) + now := time.Now().Unix() + + sessionLock.Lock() + for _, session := range sessions { + session.DelayedStatusesLock.Lock() + for chatID, delayedStatus := range session.DelayedStatuses { + if delayedStatus.TimestampExpired <= now { + go session.ProcessStatusUpdate( + chatID, + session.LastSeenStatus(delayedStatus.TimestampOnline), + "away", + ) + delete(session.DelayedStatuses, chatID) + } + } + session.DelayedStatusesLock.Unlock() + } + sessionLock.Unlock() + for key, presence := range gateway.Queue { err = gateway.ResumableSend(component, presence) if err != nil { diff --git a/xmpp/handlers.go b/xmpp/handlers.go index 6770e3a..5db8df6 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -189,8 +189,8 @@ func handlePresence(s xmpp.Sender, p stanza.Presence) { for status := range session.StatusesRange() { go session.ProcessStatusUpdate( status.ID, - status.XMPP, status.Description, + status.XMPP, gateway.SPImmed(false), ) } |