diff options
Diffstat (limited to 'xmpp/component.go')
-rw-r--r-- | xmpp/component.go | 19 |
1 files changed, 19 insertions, 0 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 { |