summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorTravis Ralston <travpc@gmail.com>2021-01-19 13:21:17 -0700
committerTravis Ralston <travpc@gmail.com>2021-01-19 13:21:17 -0700
commit95d7074322c4bfe6e24b78e9b91366933c58d316 (patch)
tree085e48e344b4d885b32ac6bd7a4d3237106cd191 /synapse/handlers
parentValidate the server name for the /publicRooms endpoint. (#9161) (diff)
downloadsynapse-95d7074322c4bfe6e24b78e9b91366933c58d316.tar.xz
Add admin APIs to force-join users to groups and manage their flair
Fixes https://github.com/matrix-org/synapse/issues/9143

Though the groups API is disappearing soon, these functions are intended to make flair management easier in the short term.
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/groups_local.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/synapse/handlers/groups_local.py b/synapse/handlers/groups_local.py

index df29edeb83..a2f16f77df 100644 --- a/synapse/handlers/groups_local.py +++ b/synapse/handlers/groups_local.py
@@ -365,6 +365,32 @@ class GroupsLocalHandler(GroupsLocalWorkerHandler): return {} + async def force_join_user_to_group(self, group_id, user_id): + """Forces a user to join a group. + """ + if not self.is_mine_id(group_id): + raise SynapseError(400, "Can only affect local groups") + + if not self.is_mine_id(user_id): + raise SynapseError(400, "Can only affect local users") + + # Bypass the group server to avoid business logic regarding whether or not + # the user can actually join. + await self.store.add_user_to_group(group_id, user_id) + + token = await self.store.register_user_group_membership( + group_id, + user_id, + membership="join", + is_admin=False, + local_attestation=None, + remote_attestation=None, + is_publicised=False, + ) + self.notifier.on_new_event("groups_key", token, users=[user_id]) + + return {} + async def accept_invite(self, group_id, user_id, content): """Accept an invite to a group """