summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-03-21 14:03:20 +0000
committerErik Johnston <erik@matrix.org>2016-03-21 15:06:07 +0000
commit3e7fac0d56dca5b389ef7a671c1cd6b0795724c8 (patch)
treeaaec44f0969cbdbe8bee11b262f8500e1ff08e3a /synapse/handlers
parentMerge pull request #655 from matrix-org/erikj/edu_yield (diff)
downloadsynapse-3e7fac0d56dca5b389ef7a671c1cd6b0795724c8.tar.xz
Add published room list edit API
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/directory.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/synapse/handlers/directory.py b/synapse/handlers/directory.py
index 6bcc5a5e2b..b2617c8898 100644
--- a/synapse/handlers/directory.py
+++ b/synapse/handlers/directory.py
@@ -317,3 +317,19 @@ class DirectoryHandler(BaseHandler):
 
         is_admin = yield self.auth.is_server_admin(UserID.from_string(user_id))
         defer.returnValue(is_admin)
+
+    @defer.inlineCallbacks
+    def edit_published_room_list(self, requester, room_id, visibility):
+        if requester.is_guest:
+            raise AuthError(403, "Guests cannot edit the published room list")
+
+        if visibility not in ["public", "private"]:
+            raise SynapseError(400, "Invalide visibility setting")
+
+        room = yield self.store.get_room(room_id)
+        if room is None:
+            raise SynapseError(400, "Unknown room")
+
+        yield self.auth.check_can_change_room_list(room_id, requester.user)
+
+        yield self.store.set_room_is_public(room_id, visibility == "public")