create_group

pull/7363/head
Andrew Morgan 2020-04-30 00:38:15 +01:00
parent bf700782fa
commit d205f69210
2 changed files with 13 additions and 15 deletions

View File

@ -787,9 +787,8 @@ class GroupsServerHandler(GroupsServerWorkerHandler):
return {} return {}
@defer.inlineCallbacks async def create_group(self, group_id, requester_user_id, content):
def create_group(self, group_id, requester_user_id, content): group = await self.check_group_is_ours(group_id, requester_user_id)
group = yield self.check_group_is_ours(group_id, requester_user_id)
logger.info("Attempting to create group with ID: %r", group_id) logger.info("Attempting to create group with ID: %r", group_id)
@ -799,7 +798,7 @@ class GroupsServerHandler(GroupsServerWorkerHandler):
if group: if group:
raise SynapseError(400, "Group already exists") raise SynapseError(400, "Group already exists")
is_admin = yield self.auth.is_server_admin( is_admin = await self.auth.is_server_admin(
UserID.from_string(requester_user_id) UserID.from_string(requester_user_id)
) )
if not is_admin: if not is_admin:
@ -822,7 +821,7 @@ class GroupsServerHandler(GroupsServerWorkerHandler):
long_description = profile.get("long_description") long_description = profile.get("long_description")
user_profile = content.get("user_profile", {}) user_profile = content.get("user_profile", {})
yield self.store.create_group( await self.store.create_group(
group_id, group_id,
requester_user_id, requester_user_id,
name=name, name=name,
@ -834,7 +833,7 @@ class GroupsServerHandler(GroupsServerWorkerHandler):
if not self.hs.is_mine_id(requester_user_id): if not self.hs.is_mine_id(requester_user_id):
remote_attestation = content["attestation"] remote_attestation = content["attestation"]
yield self.attestations.verify_attestation( await self.attestations.verify_attestation(
remote_attestation, user_id=requester_user_id, group_id=group_id remote_attestation, user_id=requester_user_id, group_id=group_id
) )
@ -845,7 +844,7 @@ class GroupsServerHandler(GroupsServerWorkerHandler):
local_attestation = None local_attestation = None
remote_attestation = None remote_attestation = None
yield self.store.add_user_to_group( await self.store.add_user_to_group(
group_id, group_id,
requester_user_id, requester_user_id,
is_admin=True, is_admin=True,
@ -855,7 +854,7 @@ class GroupsServerHandler(GroupsServerWorkerHandler):
) )
if not self.hs.is_mine_id(requester_user_id): if not self.hs.is_mine_id(requester_user_id):
yield self.store.add_remote_profile_cache( await self.store.add_remote_profile_cache(
requester_user_id, requester_user_id,
displayname=user_profile.get("displayname"), displayname=user_profile.get("displayname"),
avatar_url=user_profile.get("avatar_url"), avatar_url=user_profile.get("avatar_url"),

View File

@ -284,15 +284,14 @@ class GroupsLocalHandler(GroupsLocalWorkerHandler):
set_group_join_policy = _create_rerouter("set_group_join_policy") set_group_join_policy = _create_rerouter("set_group_join_policy")
@defer.inlineCallbacks async def create_group(self, group_id, user_id, content):
def create_group(self, group_id, user_id, content):
"""Create a group """Create a group
""" """
logger.info("Asking to create group with ID: %r", group_id) logger.info("Asking to create group with ID: %r", group_id)
if self.is_mine_id(group_id): if self.is_mine_id(group_id):
res = yield self.groups_server_handler.create_group( res = await self.groups_server_handler.create_group(
group_id, user_id, content group_id, user_id, content
) )
local_attestation = None local_attestation = None
@ -301,10 +300,10 @@ class GroupsLocalHandler(GroupsLocalWorkerHandler):
local_attestation = self.attestations.create_attestation(group_id, user_id) local_attestation = self.attestations.create_attestation(group_id, user_id)
content["attestation"] = local_attestation content["attestation"] = local_attestation
content["user_profile"] = yield self.profile_handler.get_profile(user_id) content["user_profile"] = await self.profile_handler.get_profile(user_id)
try: try:
res = yield self.transport_client.create_group( res = await self.transport_client.create_group(
get_domain_from_id(group_id), group_id, user_id, content get_domain_from_id(group_id), group_id, user_id, content
) )
except HttpResponseException as e: except HttpResponseException as e:
@ -313,7 +312,7 @@ class GroupsLocalHandler(GroupsLocalWorkerHandler):
raise SynapseError(502, "Failed to contact group server") raise SynapseError(502, "Failed to contact group server")
remote_attestation = res["attestation"] remote_attestation = res["attestation"]
yield self.attestations.verify_attestation( await self.attestations.verify_attestation(
remote_attestation, remote_attestation,
group_id=group_id, group_id=group_id,
user_id=user_id, user_id=user_id,
@ -321,7 +320,7 @@ class GroupsLocalHandler(GroupsLocalWorkerHandler):
) )
is_publicised = content.get("publicise", False) is_publicised = content.get("publicise", False)
token = yield self.store.register_user_group_membership( token = await self.store.register_user_group_membership(
group_id, group_id,
user_id, user_id,
membership="join", membership="join",