summary refs log tree commit diff
path: root/synapse/federation
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-09-26 15:52:41 +0100
committerErik Johnston <erik@matrix.org>2017-09-26 15:52:41 +0100
commit17b8e2bd02ad0abbd25103b637eb8490f3a53507 (patch)
tree889b3b1cbfc30181fe7c9e67e122d3c0f1cc5d03 /synapse/federation
parentAdd unique index to group_rooms table (diff)
downloadsynapse-17b8e2bd02ad0abbd25103b637eb8490f3a53507.tar.xz
Add remove room API
Diffstat (limited to 'synapse/federation')
-rw-r--r--synapse/federation/transport/client.py12
-rw-r--r--synapse/federation/transport/server.py14
2 files changed, 25 insertions, 1 deletions
diff --git a/synapse/federation/transport/client.py b/synapse/federation/transport/client.py
index ce68cc4937..36f6eb75e9 100644
--- a/synapse/federation/transport/client.py
+++ b/synapse/federation/transport/client.py
@@ -525,6 +525,18 @@ class TransportLayerClient(object):
             ignore_backoff=True,
         )
 
+    def remove_room_from_group(self, destination, group_id, requester_user_id, room_id):
+        """Remove a room from a group
+        """
+        path = PREFIX + "/groups/%s/room/%s" % (group_id, room_id,)
+
+        return self.client.delete_json(
+            destination=destination,
+            path=path,
+            args={"requester_user_id": requester_user_id},
+            ignore_backoff=True,
+        )
+
     @log_function
     def get_users_in_group(self, destination, group_id, requester_user_id):
         """Get users in a group
diff --git a/synapse/federation/transport/server.py b/synapse/federation/transport/server.py
index b5f07c50bf..c7565e0737 100644
--- a/synapse/federation/transport/server.py
+++ b/synapse/federation/transport/server.py
@@ -674,7 +674,7 @@ class FederationGroupsRoomsServlet(BaseFederationServlet):
 
 
 class FederationGroupsAddRoomsServlet(BaseFederationServlet):
-    """Add room to group
+    """Add/remove room from group
     """
     PATH = "/groups/(?P<group_id>[^/]*)/room/(?<room_id>)$"
 
@@ -690,6 +690,18 @@ class FederationGroupsAddRoomsServlet(BaseFederationServlet):
 
         defer.returnValue((200, new_content))
 
+    @defer.inlineCallbacks
+    def on_DELETE(self, origin, content, query, group_id, room_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.remove_room_from_group(
+            group_id, requester_user_id, room_id,
+        )
+
+        defer.returnValue((200, new_content))
+
 
 class FederationGroupsUsersServlet(BaseFederationServlet):
     """Get the users in a group on behalf of a user