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

Fix only handling the last presence state for each user #9425

Merged
merged 4 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions changelog.d/9425.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a long-standing bug in the deduplication of old presence, resulting in no deduplication.
7 changes: 5 additions & 2 deletions synapse/handlers/presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,13 @@ async def _persist_unpersisted_changes(self):
[self.user_to_current_state[user_id] for user_id in unpersisted]
)

async def _update_states(self, new_states):
async def _update_states(self, new_states: Iterable[UserPresenceState]) -> None:
"""Updates presence of users. Sets the appropriate timeouts. Pokes
the notifier and federation if and only if the changed presence state
should be sent to clients/servers.

Args:
new_states: The new user presence state updates to process.
"""
now = self.clock.time_msec()

Expand All @@ -368,7 +371,7 @@ async def _update_states(self, new_states):
new_states_dict = {}
for new_state in new_states:
new_states_dict[new_state.user_id] = new_state
new_state = new_states_dict.values()
new_states = new_states_dict.values()

for new_state in new_states:
user_id = new_state.user_id
Expand Down