Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add is_blocked to worker store #2993

Merged
merged 1 commit into from
Mar 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions synapse/storage/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ def get_public_room_changes_txn(txn):
"get_public_room_changes", get_public_room_changes_txn
)

@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",
)


class RoomStore(RoomWorkerStore, SearchStore):

Expand Down Expand Up @@ -485,18 +497,6 @@ def get_ratelimit_for_user(self, user_id):
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(
Expand All @@ -507,7 +507,11 @@ def block_room(self, room_id, user_id):
},
desc="block_room",
)
self.is_room_blocked.invalidate((room_id,))
yield self.runInteraction(
"block_room_invalidation",
self._invalidate_cache_and_stream,
self.is_room_blocked, (room_id,),
)

def get_media_mxcs_in_room(self, room_id):
"""Retrieves all the local and remote media MXC URIs in a given room
Expand Down