diff options
author | Luke Barnard <lukebarnard1@users.noreply.github.com> | 2018-04-06 16:24:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-06 16:24:32 +0100 |
commit | 135fc5b9cdbae9544f9ae9612fcbde989e26eb55 (patch) | |
tree | 20240b323f30e1f2dca14629b6ec9753cdc9017f /synapse/handlers | |
parent | Merge pull request #3071 from matrix-org/erikj/resp_size_metrics (diff) | |
parent | de-lint, quote consistency (diff) | |
download | synapse-135fc5b9cdbae9544f9ae9612fcbde989e26eb55.tar.xz |
Merge pull request #3046 from matrix-org/dbkr/join_group
Implement group join API
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/groups_local.py | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/synapse/handlers/groups_local.py b/synapse/handlers/groups_local.py index 5f7b0ff305..977993e7d4 100644 --- a/synapse/handlers/groups_local.py +++ b/synapse/handlers/groups_local.py @@ -229,7 +229,45 @@ class GroupsLocalHandler(object): def join_group(self, group_id, user_id, content): """Request to join a group """ - raise NotImplementedError() # TODO + if self.is_mine_id(group_id): + yield self.groups_server_handler.join_group( + group_id, user_id, content + ) + local_attestation = None + remote_attestation = None + else: + local_attestation = self.attestations.create_attestation(group_id, user_id) + content["attestation"] = local_attestation + + res = yield self.transport_client.join_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, + server_name=get_domain_from_id(group_id), + ) + + # TODO: Check that the group is public and we're being added publically + is_publicised = content.get("publicise", False) + + token = yield self.store.register_user_group_membership( + group_id, user_id, + membership="join", + is_admin=False, + 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({}) @defer.inlineCallbacks def accept_invite(self, group_id, user_id, content): |