Skip to content

Commit

Permalink
Combine the condition checking previous state to new state so that la…
Browse files Browse the repository at this point in the history
…st_active_ts is updated if we were anything but already ONLINE
  • Loading branch information
realtyem committed Aug 3, 2023
1 parent bf71e78 commit 6b7e273
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions synapse/handlers/presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ async def set_state(
new_fields["status_msg"] = status_msg

if (
prev_state.state == PresenceState.OFFLINE
prev_state.state != PresenceState.ONLINE
and presence == PresenceState.ONLINE
) or (presence == PresenceState.BUSY and self._busy_presence_enabled):
# By updating last_active_ts in this way, currently_active will be triggered
Expand Down Expand Up @@ -1982,14 +1982,6 @@ 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
)

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

0 comments on commit 6b7e273

Please sign in to comment.