summary refs log tree commit diff
path: root/synapse/storage/room.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2017-06-19 16:20:55 +0100
committerGitHub <noreply@github.com>2017-06-19 16:20:55 +0100
commitb5f665de3209aa77ac9f692a515e4f96444b9003 (patch)
treedfa58ac75e65b503472bc603a9601bc0295a02b7 /synapse/storage/room.py
parentadd missing boolean to synapse_port_db (diff)
parentHandle all cases of sending membership events (diff)
downloadsynapse-b5f665de3209aa77ac9f692a515e4f96444b9003.tar.xz
Merge pull request #2291 from matrix-org/erikj/shutdown_room
Add shutdown room API
Diffstat (limited to 'synapse/storage/room.py')
-rw-r--r--synapse/storage/room.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/synapse/storage/room.py b/synapse/storage/room.py
index 5d543652bb..07366f66b6 100644
--- a/synapse/storage/room.py
+++ b/synapse/storage/room.py
@@ -507,3 +507,27 @@ class RoomStore(SQLBaseStore):
             ))
         else:
             defer.returnValue(None)
+
+    @cached(max_entries=10000)
+    def is_room_blocked(self, room_id):
+        return self._simple_select_one_onecol(
+            table="blocked_rooms",
+            keyvalues={
+                "room_id": room_id,
+            },
+            retcol="1",
+            allow_none=True,
+            desc="is_room_blocked",
+        )
+
+    @defer.inlineCallbacks
+    def block_room(self, room_id, user_id):
+        yield self._simple_insert(
+            table="blocked_rooms",
+            values={
+                "room_id": room_id,
+                "user_id": user_id,
+            },
+            desc="block_room",
+        )
+        self.is_room_blocked.invalidate((room_id,))