diff options
author | Luke Barnard <lukebarnard1@users.noreply.github.com> | 2017-10-16 17:33:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-16 17:33:33 +0200 |
commit | e0a75e0c253321bca6f00f79815eac11ce003988 (patch) | |
tree | 68e666ef8c0c3f478aba9dab51c1d7c66cad9f5b /synapse/groups/groups_server.py | |
parent | Merge pull request #2543 from matrix-org/luke/fix-on-group-invite-no-profile (diff) | |
parent | Delint (diff) | |
download | synapse-e0a75e0c253321bca6f00f79815eac11ce003988.tar.xz |
Merge pull request #2544 from matrix-org/luke/groups-invited-users
Implement GET /groups/$groupId/invited_users
Diffstat (limited to 'synapse/groups/groups_server.py')
-rw-r--r-- | synapse/groups/groups_server.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/synapse/groups/groups_server.py b/synapse/groups/groups_server.py index 1083bc2990..a3a500b9d6 100644 --- a/synapse/groups/groups_server.py +++ b/synapse/groups/groups_server.py @@ -421,6 +421,40 @@ class GroupsServerHandler(object): }) @defer.inlineCallbacks + def get_invited_users_in_group(self, group_id, requester_user_id): + """Get the users that have been invited to a group as seen by requester_user_id. + + The ordering is arbitrary at the moment + """ + + yield self.check_group_is_ours(group_id, and_exists=True) + + is_user_in_group = yield self.store.is_user_in_group(requester_user_id, group_id) + + if not is_user_in_group: + raise SynapseError(403, "User not in group") + + invited_users = yield self.store.get_invited_users_in_group(group_id) + + user_profiles = [] + + for user_id in invited_users: + user_profile = { + "user_id": user_id + } + try: + profile = yield self.profile_handler.get_profile_from_cache(user_id) + user_profile.update(profile) + except Exception as e: + logger.warn("Error getting profile for %s: %s", user_id, e) + user_profiles.append(user_profile) + + defer.returnValue({ + "chunk": user_profiles, + "total_user_count_estimate": len(invited_users), + }) + + @defer.inlineCallbacks def get_rooms_in_group(self, group_id, requester_user_id): """Get the rooms in group as seen by requester_user_id |