summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-08-11 13:42:42 +0100
committerErik Johnston <erik@matrix.org>2017-08-11 13:42:42 +0100
commitba3ff7918b54ae431aaaedb3d12650c93d366c04 (patch)
tree66f80ef374081f6b94668796f0d3092778962591 /synapse
parentAdd bulk group publicised lookup API (diff)
downloadsynapse-ba3ff7918b54ae431aaaedb3d12650c93d366c04.tar.xz
Fixup
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/groups_local.py22
-rw-r--r--synapse/rest/client/v2_alpha/groups.py1
2 files changed, 14 insertions, 9 deletions
diff --git a/synapse/handlers/groups_local.py b/synapse/handlers/groups_local.py
index c980623bbc..274fed9278 100644
--- a/synapse/handlers/groups_local.py
+++ b/synapse/handlers/groups_local.py
@@ -329,27 +329,31 @@ class GroupsLocalHandler(object):
     @defer.inlineCallbacks
     def bulk_get_publicised_groups(self, user_ids, proxy=True):
         destinations = {}
-        locals = []
+        local_users = set()
 
         for user_id in user_ids:
             if self.hs.is_mine_id(user_id):
-                locals.append(user_id)
+                local_users.add(user_id)
             else:
                 destinations.setdefault(
-                    get_domain_from_id(user_id), []
-                ).append(user_id)
+                    get_domain_from_id(user_id), set()
+                ).add(user_id)
 
         if not proxy and destinations:
             raise SynapseError(400, "Some user_ids are not local")
 
         results = {}
+        failed_results = []
         for destination, dest_user_ids in destinations.iteritems():
-            r = yield self.transport_client.bulk_get_publicised_groups(
-                destination, dest_user_ids,
-            )
-            results.update(r)
+            try:
+                r = yield self.transport_client.bulk_get_publicised_groups(
+                    destination, list(dest_user_ids),
+                )
+                results.update(r["users"])
+            except Exception:
+                failed_results.extend(dest_user_ids)
 
-        for uid in locals:
+        for uid in local_users:
             results[uid] = yield self.store.get_publicised_groups_for_user(
                 uid
             )
diff --git a/synapse/rest/client/v2_alpha/groups.py b/synapse/rest/client/v2_alpha/groups.py
index 97d7948bb9..b469058e9d 100644
--- a/synapse/rest/client/v2_alpha/groups.py
+++ b/synapse/rest/client/v2_alpha/groups.py
@@ -681,3 +681,4 @@ def register_servlets(hs, http_server):
     GroupSelfUpdatePublicityServlet(hs).register(http_server)
     GroupSummaryUsersRoleServlet(hs).register(http_server)
     PublicisedGroupsForUserServlet(hs).register(http_server)
+    PublicisedGroupsForUsersServlet(hs).register(http_server)