summary refs log tree commit diff
path: root/synapse/handlers/message.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2017-09-27 16:42:23 +0100
committerGitHub <noreply@github.com>2017-09-27 16:42:23 +0100
commit3a743f649c548df1df05a5b93ba1f57c7587eff6 (patch)
treebd8a82c2190f9d632944e071c9b51ce005926696 /synapse/handlers/message.py
parentMerge pull request #2474 from matrix-org/dbkr/spam_check_module (diff)
parentFix bug where /joined_members didn't check user was in room (diff)
downloadsynapse-3a743f649c548df1df05a5b93ba1f57c7587eff6.tar.xz
Merge pull request #2475 from matrix-org/erikj/joined_members_auth
Fix bug where /joined_members didn't check user was in room
Diffstat (limited to 'synapse/handlers/message.py')
-rw-r--r--synapse/handlers/message.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 37f0a2772a..f6740544c1 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -419,6 +419,37 @@ class MessageHandler(BaseHandler):
             [serialize_event(c, now) for c in room_state.values()]
         )
 
+    @defer.inlineCallbacks
+    def get_joined_members(self, user_id, room_id):
+        """Get all the joined members in the room and their profile information.
+
+        If the user has left the room return the state events from when they left.
+
+        Args:
+            user_id(str): The user requesting state events.
+            room_id(str): The room ID to get all state events from.
+        Returns:
+            A dict of user_id to profile info
+        """
+        membership, membership_event_id = yield self._check_in_room_or_world_readable(
+            room_id, user_id
+        )
+
+        if membership == Membership.JOIN:
+            users_with_profile = yield self.state.get_current_user_in_room(room_id)
+        else:
+            raise NotImplementedError(
+                "Getting joined members after leaving is not implemented"
+            )
+
+        defer.returnValue({
+            user_id: {
+                "avatar_url": profile.avatar_url,
+                "display_name": profile.display_name,
+            }
+            for user_id, profile in users_with_profile.iteritems()
+        })
+
     @measure_func("_create_new_client_event")
     @defer.inlineCallbacks
     def _create_new_client_event(self, builder, requester=None, prev_event_ids=None):