Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Presence fix for idle mode #15989

Closed
8 changes: 8 additions & 0 deletions synapse/handlers/presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1982,6 +1982,14 @@ def handle_update(
obj=user_id,
then=new_state.last_active_ts + LAST_ACTIVE_GRANULARITY,
)
if prev_state.state == PresenceState.UNAVAILABLE:
# If we had idled out, but are still syncing, then new state will look
# like it's online. Verify with last_active_ts, as that is a sign of a
# pro-active event. Override that we are online when we probably aren't.
if now - new_state.last_active_ts > IDLE_TIMER:
new_state = new_state.copy_and_replace(
state=PresenceState.UNAVAILABLE
)
Comment on lines +1985 to +1992
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit hacky -- can we avoid trying to update in this case at all instead backtracking from saying we're online to unavailable?


if new_state.state != PresenceState.OFFLINE:
# User has stopped syncing
Expand Down