diff options
author | Erik Johnston <erik@matrix.org> | 2017-09-27 15:01:25 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2017-09-27 15:14:39 +0100 |
commit | adec03395d1c9a8e237a74ea420966bae8ea0002 (patch) | |
tree | bd8a82c2190f9d632944e071c9b51ce005926696 /synapse/handlers/message.py | |
parent | Merge pull request #2474 from matrix-org/dbkr/spam_check_module (diff) | |
download | synapse-adec03395d1c9a8e237a74ea420966bae8ea0002.tar.xz |
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.py | 31 |
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): |