aboutsummaryrefslogtreecommitdiff
path: root/xmpp
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-01-31 17:31:05 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-01-31 17:31:05 +0300
commit3cdb625c5edb90ad6c55bacc2daea51385952750 (patch)
treeea65e10369eda6583b9508094ffe421f548b8062 /xmpp
parent8c20aaa30d2ca7483e56c2a3cb95e83a051013ea (diff)
Mark expired online statuses as away
Diffstat (limited to 'xmpp')
-rw-r--r--xmpp/component.go19
-rw-r--r--xmpp/handlers.go2
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),
)
}