summary refs log tree commit diff
path: root/synapse/handlers/groups_local.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2017-09-19 11:21:26 +0100
committerGitHub <noreply@github.com>2017-09-19 11:21:26 +0100
commit47d9848dc4bc08076a582eebb5fa90de7fc3df28 (patch)
tree1d4727d913ce6bc99b3a11c7daff32ea59907e83 /synapse/handlers/groups_local.py
parentMerge branch 'develop' of github.com:matrix-org/synapse into erikj/groups_merged (diff)
parentEnsure that creator of group sees group down /sync (diff)
downloadsynapse-47d9848dc4bc08076a582eebb5fa90de7fc3df28.tar.xz
Merge pull request #2454 from matrix-org/erikj/groups_sync_creator
	Ensure that creator of group sees group down /sync
Diffstat (limited to 'synapse/handlers/groups_local.py')
-rw-r--r--synapse/handlers/groups_local.py34
1 files changed, 30 insertions, 4 deletions
diff --git a/synapse/handlers/groups_local.py b/synapse/handlers/groups_local.py
index 1950c12f1f..b4833f8ef8 100644
--- a/synapse/handlers/groups_local.py
+++ b/synapse/handlers/groups_local.py
@@ -136,12 +136,38 @@ class GroupsLocalHandler(object):
             res = yield self.groups_server_handler.create_group(
                 group_id, user_id, content
             )
-            defer.returnValue(res)
+            local_attestation = None
+            remote_attestation = None
+        else:
+            local_attestation = self.attestations.create_attestation(group_id, user_id)
+            content["attestation"] = local_attestation
+
+            content["user_profile"] = yield self.profile_handler.get_profile(user_id)
+
+            res = yield self.transport_client.create_group(
+                get_domain_from_id(group_id), group_id, user_id, content,
+            )
+
+            remote_attestation = res["attestation"]
+            yield self.attestations.verify_attestation(
+                remote_attestation,
+                group_id=group_id,
+                user_id=user_id,
+            )
 
-        content["user_profile"] = yield self.profile_handler.get_profile(user_id)
-        res = yield self.transport_client.create_group(
-            get_domain_from_id(group_id), group_id, user_id, content,
+        is_publicised = content.get("publicise", False)
+        token = yield self.store.register_user_group_membership(
+            group_id, user_id,
+            membership="join",
+            is_admin=True,
+            local_attestation=local_attestation,
+            remote_attestation=remote_attestation,
+            is_publicised=is_publicised,
         )
+        self.notifier.on_new_event(
+            "groups_key", token, users=[user_id],
+        )
+
         defer.returnValue(res)
 
     @defer.inlineCallbacks