From ce6d4914f4e02a812643de252d8d456a84102893 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 23 Oct 2017 15:19:28 +0100 Subject: [PATCH] Correctly wire in update group profile over federation --- synapse/federation/transport/client.py | 20 ++++++++++++++++++++ synapse/federation/transport/server.py | 26 +++++++++++++------------- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/synapse/federation/transport/client.py b/synapse/federation/transport/client.py index 125d8f359..d25ae1b28 100644 --- a/synapse/federation/transport/client.py +++ b/synapse/federation/transport/client.py @@ -485,6 +485,26 @@ class TransportLayerClient(object): ignore_backoff=True, ) + @log_function + def update_group_profile(self, destination, group_id, requester_user_id, content): + """Update a remote group profile + + Args: + destination (str) + group_id (str) + requester_user_id (str) + content (dict): The new profile of the group + """ + path = PREFIX + "/groups/%s/profile" % (group_id,) + + return self.client.post_json( + destination=destination, + path=path, + args={"requester_user_id": requester_user_id}, + data=content, + ignore_backoff=True, + ) + @log_function def get_group_summary(self, destination, group_id, requester_user_id): """Get a group summary diff --git a/synapse/federation/transport/server.py b/synapse/federation/transport/server.py index f0778c65c..8e08321fe 100644 --- a/synapse/federation/transport/server.py +++ b/synapse/federation/transport/server.py @@ -610,7 +610,7 @@ class FederationVersionServlet(BaseFederationServlet): class FederationGroupsProfileServlet(BaseFederationServlet): - """Get the basic profile of a group on behalf of a user + """Get/set the basic profile of a group on behalf of a user """ PATH = "/groups/(?P[^/]*)/profile$" @@ -626,6 +626,18 @@ class FederationGroupsProfileServlet(BaseFederationServlet): defer.returnValue((200, new_content)) + @defer.inlineCallbacks + def on_POST(self, origin, content, query, group_id): + requester_user_id = parse_string_from_args(query, "requester_user_id") + if get_domain_from_id(requester_user_id) != origin: + raise SynapseError(403, "requester_user_id doesn't match origin") + + new_content = yield self.handler.update_group_profile( + group_id, requester_user_id, content + ) + + defer.returnValue((200, new_content)) + class FederationGroupsSummaryServlet(BaseFederationServlet): PATH = "/groups/(?P[^/]*)/summary$" @@ -642,18 +654,6 @@ class FederationGroupsSummaryServlet(BaseFederationServlet): defer.returnValue((200, new_content)) - @defer.inlineCallbacks - def on_POST(self, origin, content, query, group_id): - requester_user_id = parse_string_from_args(query, "requester_user_id") - if get_domain_from_id(requester_user_id) != origin: - raise SynapseError(403, "requester_user_id doesn't match origin") - - new_content = yield self.handler.update_group_profile( - group_id, requester_user_id, content - ) - - defer.returnValue((200, new_content)) - class FederationGroupsRoomsServlet(BaseFederationServlet): """Get the rooms in a group on behalf of a user