summary refs log tree commit diff
path: root/synapse/groups
diff options
context:
space:
mode:
authorLuke Barnard <lukeb@openmarket.com>2017-10-16 15:31:11 +0100
committerLuke Barnard <lukeb@openmarket.com>2017-10-16 15:31:11 +0100
commit2c5972f87f0541aaeff43846f7050ab91d11cf0e (patch)
tree9d58fc7426e62ed576a4ede3f8a59d9825025dec /synapse/groups
parentLog a warning when no profile for invited member (diff)
downloadsynapse-2c5972f87f0541aaeff43846f7050ab91d11cf0e.tar.xz
Implement GET /groups/$groupId/invited_users
Diffstat (limited to 'synapse/groups')
-rw-r--r--synapse/groups/groups_server.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/synapse/groups/groups_server.py b/synapse/groups/groups_server.py
index 1083bc2990..bfa46b7cb2 100644
--- a/synapse/groups/groups_server.py
+++ b/synapse/groups/groups_server.py
@@ -421,6 +421,41 @@ 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)
+                user_profile.update(profile)
+            except Exception as e:
+                pass
+            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