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

Combine logic about not overriding BUSY presence. #16170

Merged
merged 7 commits into from
Aug 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Combine setting the last_user_sync_ts.
Building on the previous commit, last_user_sync_ts can now be set
based on the is_sync flag.
  • Loading branch information
clokep committed Aug 23, 2023
commit bd473d7fffc465921b93cabfb1cdad641252907a
15 changes: 5 additions & 10 deletions synapse/handlers/presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,18 +1017,9 @@ async def user_syncing(
prev_state.copy_and_replace(
state=PresenceState.ONLINE,
last_active_ts=self.clock.time_msec(),
last_user_sync_ts=self.clock.time_msec(),
)
]
)
# otherwise, set the new presence state & update the last sync time,
# but don't update last_active_ts as this isn't an indication that
# they've been active (even though it's probably been updated by
# set_state above)
else:
await self._update_states(
[prev_state.copy_and_replace(last_user_sync_ts=self.clock.time_msec())]
)

async def _end() -> None:
try:
Expand Down Expand Up @@ -1227,6 +1218,7 @@ async def set_state(
return

user_id = target_user.to_string()
now = self.clock.time_msec()

prev_state = await self.current_state_for_user(user_id)

Expand All @@ -1245,7 +1237,10 @@ async def set_state(
if presence == PresenceState.ONLINE or (
presence == PresenceState.BUSY and self._busy_presence_enabled
):
new_fields["last_active_ts"] = self.clock.time_msec()
new_fields["last_active_ts"] = now

if is_sync:
new_fields["last_user_sync_ts"] = now

await self._update_states(
[prev_state.copy_and_replace(**new_fields)], force_notify=force_notify
Expand Down