summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2020-03-27 12:26:47 +0000
committerDavid Baker <dave@matrix.org>2020-03-27 12:26:47 +0000
commit09cc058a4c3eae58ee6e08c1925bffd9cf7d52c6 (patch)
tree38c7916c0b46605fab9a7de06011f72ca68477ff
parentMerge pull request #7151 from matrix-org/jaywink/saml-redirect-fix (diff)
downloadsynapse-09cc058a4c3eae58ee6e08c1925bffd9cf7d52c6.tar.xz
Always send the user updates to their own device list
This will allow clients to notify users about new devices even if
the user isn't in any rooms (yet).
-rw-r--r--synapse/handlers/device.py19
-rw-r--r--synapse/handlers/sync.py7
2 files changed, 20 insertions, 6 deletions
diff --git a/synapse/handlers/device.py b/synapse/handlers/device.py
index a514c30714..54931c355b 100644
--- a/synapse/handlers/device.py
+++ b/synapse/handlers/device.py
@@ -122,11 +122,22 @@ class DeviceWorkerHandler(BaseHandler):
 
         # First we check if any devices have changed for users that we share
         # rooms with.
-        users_who_share_room = yield self.store.get_users_who_share_room_with_user(
+        tracked_users = yield self.store.get_users_who_share_room_with_user(
             user_id
         )
+        # always tell the user about their own devices
+        tracked_users.add(user_id)
+
+        logger.info(
+            "tracked users ids: %r", tracked_users,
+        )
+
         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
+        )
+
+        logger.info(
+            "changed users IDs: %r", changed,
         )
 
         # Then work out if any users have since joined
@@ -456,7 +467,9 @@ class DeviceHandler(DeviceWorkerHandler):
 
         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(
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py
index 5746fdea14..fd68a31b09 100644
--- a/synapse/handlers/sync.py
+++ b/synapse/handlers/sync.py
@@ -1139,13 +1139,14 @@ class SyncHandler(object):
             # room with by looking at all users that have left a room plus users
             # that were in a room we've left.
 
-            users_who_share_room = await self.store.get_users_who_share_room_with_user(
+            users_we_track = await self.store.get_users_who_share_room_with_user(
                 user_id
             )
+            users_we_track.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, users_we_track
             )
 
             # Step 1b, check for newly joined rooms
@@ -1168,7 +1169,7 @@ class SyncHandler(object):
                 newly_left_users.update(left_users)
 
             # Remove any users that we still share a room with.
-            newly_left_users -= users_who_share_room
+            newly_left_users -= users_we_track
 
             return DeviceLists(changed=users_that_have_changed, left=newly_left_users)
         else: