summary refs log tree commit diff
path: root/synapse/handlers/room.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-03-18 15:44:37 +0000
committerErik Johnston <erik@matrix.org>2019-03-18 15:51:00 +0000
commitfeae38757603828839670a918f50938a4a4eb2a6 (patch)
tree7ff26a2f42517c65b62a223e2f53ee86cc7dcd96 /synapse/handlers/room.py
parentRun black on tests/rulecheck/test_domainrulecheck.py (diff)
downloadsynapse-feae38757603828839670a918f50938a4a4eb2a6.tar.xz
Don't spam check actions by admins
Diffstat (limited to 'synapse/handlers/room.py')
-rw-r--r--synapse/handlers/room.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index 2d42a41134..581cff9526 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -81,6 +81,8 @@ class RoomCreationHandler(BaseHandler):
         # linearizer to stop two upgrades happening at once
         self._upgrade_linearizer = Linearizer("room_upgrade_linearizer")
 
+        self._server_notices_mxid = hs.config.server_notices_mxid
+
     @defer.inlineCallbacks
     def upgrade_room(self, requester, old_room_id, new_version):
         """Replace a room with a new room with a different version
@@ -254,7 +256,17 @@ class RoomCreationHandler(BaseHandler):
         """
         user_id = requester.user.to_string()
 
-        if not self.spam_checker.user_may_create_room(
+        if (self._server_notices_mxid is not None and
+                requester.user.to_string() == self._server_notices_mxid):
+            # allow the server notices mxid to create rooms
+            is_requester_admin = True
+
+        else:
+            is_requester_admin = yield self.auth.is_server_admin(
+                requester.user,
+            )
+
+        if not is_requester_admin and not self.spam_checker.user_may_create_room(
             user_id,
             invite_list=[],
             cloning=True,
@@ -481,7 +493,16 @@ class RoomCreationHandler(BaseHandler):
 
         invite_list = config.get("invite", [])
 
-        if not self.spam_checker.user_may_create_room(
+        if (self._server_notices_mxid is not None and
+                requester.user.to_string() == self._server_notices_mxid):
+            # allow the server notices mxid to create rooms
+            is_requester_admin = True
+        else:
+            is_requester_admin = yield self.auth.is_server_admin(
+                requester.user,
+            )
+
+        if not is_requester_admin and not self.spam_checker.user_may_create_room(
             user_id,
             invite_list=invite_list,
             cloning=False,