Simplify presence stringification (should help with vector-im/element-android#5712)

This commit is contained in:
Neil Alexander 2022-04-07 10:10:28 +01:00
parent 99f2007eb6
commit 99ef547295
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
7 changed files with 36 additions and 87 deletions

View file

@ -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)