aboutsummaryrefslogtreecommitdiff
path: root/syncapi/streams/stream_presence.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-04-07 10:10:28 +0100
committerNeil Alexander <neilalexander@users.noreply.github.com>2022-04-07 10:10:28 +0100
commit99ef5472959a4e4d49bd9760fcb8b3872e21fa71 (patch)
treeac559cfc355cd8f61ad1f82f8ba2850097951265 /syncapi/streams/stream_presence.go
parent99f2007eb6ad75ce8e19b3c3088f552034a1644d (diff)
Simplify presence stringification (should help with vector-im/element-android#5712)
Diffstat (limited to 'syncapi/streams/stream_presence.go')
-rw-r--r--syncapi/streams/stream_presence.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/syncapi/streams/stream_presence.go b/syncapi/streams/stream_presence.go
index 6d5ec54b..9a6c5c13 100644
--- a/syncapi/streams/stream_presence.go
+++ b/syncapi/streams/stream_presence.go
@@ -111,10 +111,15 @@ func (p *PresenceStreamProvider) IncrementalSync(
continue
}
}
- presence.ClientFields.LastActiveAgo = presence.LastActiveAgo()
- if presence.ClientFields.Presence == "online" {
- currentlyActive := presence.CurrentlyActive()
- presence.ClientFields.CurrentlyActive = &currentlyActive
+
+ if _, known := types.PresenceFromString(presence.ClientFields.Presence); known {
+ presence.ClientFields.LastActiveAgo = presence.LastActiveAgo()
+ if presence.ClientFields.Presence == "online" {
+ currentlyActive := presence.CurrentlyActive()
+ presence.ClientFields.CurrentlyActive = &currentlyActive
+ }
+ } else {
+ presence.ClientFields.Presence = "offline"
}
content, err := json.Marshal(presence.ClientFields)