Skip to content

Commit

Permalink
Fixed presence results not returning offline users on initial sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Hollister committed May 24, 2024
1 parent 9edb725 commit 9e99edf
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.d/17231.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed presence results not returning offline users on initial sync. Contributed by @Michael-Hollister.
3 changes: 0 additions & 3 deletions synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -2281,16 +2281,13 @@ async def _generate_sync_entry_for_presence(

since_token = sync_result_builder.since_token
presence_key = None
include_offline = False
if since_token and not sync_result_builder.full_state:
presence_key = since_token.presence_key
include_offline = True

presence, presence_key = await presence_source.get_new_events(
user=user,
from_key=presence_key,
is_guest=sync_config.is_guest,
include_offline=include_offline,
)
assert presence_key
sync_result_builder.now_token = now_token.copy_and_replace(
Expand Down
2 changes: 1 addition & 1 deletion tests/module_api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ def _test_sending_local_online_presence_to_local_user(
presence_updates, sync_token = sync_presence(
test_case, test_case.presence_receiver_id
)
test_case.assertEqual(len(presence_updates), 1)
test_case.assertEqual(len(presence_updates), 2)

presence_update: UserPresenceState = presence_updates[0]
test_case.assertEqual(presence_update.user_id, test_case.presence_sender_id)
Expand Down

0 comments on commit 9e99edf

Please sign in to comment.