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

Always send the user updates to their own device list #7160

Merged
merged 7 commits into from
Mar 30, 2020
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/7160.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Always send users their own device updates.
14 changes: 12 additions & 2 deletions synapse/handlers/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,14 @@ def get_user_ids_changed(self, user_id, from_token):
users_who_share_room = yield self.store.get_users_who_share_room_with_user(
user_id
)

tracked_users = set(users_who_share_room)

# Always tell the user about their own devices
tracked_users.add(user_id)

changed = yield self.store.get_users_whose_devices_changed(
from_token.device_list_key, users_who_share_room
from_token.device_list_key, tracked_users
)

# Then work out if any users have since joined
Expand Down Expand Up @@ -456,7 +462,11 @@ def notify_device_update(self, user_id, device_ids):

room_ids = yield self.store.get_rooms_for_user(user_id)

yield self.notifier.on_new_event("device_list_key", position, rooms=room_ids)
# specify the user ID too since the user should always get their own device list
# updates, even if they aren't in any rooms.
yield self.notifier.on_new_event(
"device_list_key", position, users=[user_id], rooms=room_ids
)

if hosts:
logger.info(
Expand Down
7 changes: 6 additions & 1 deletion synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,9 +1143,14 @@ async def _generate_sync_entry_for_device_list(
user_id
)

tracked_users = set(users_who_share_room)

# Always tell the user about their own devices
tracked_users.add(user_id)

# Step 1a, check for changes in devices of users we share a room with
users_that_have_changed = await self.store.get_users_whose_devices_changed(
since_token.device_list_key, users_who_share_room
since_token.device_list_key, tracked_users
)

# Step 1b, check for newly joined rooms
Expand Down