Skip to content
Snippets Groups Projects
Commit 627ecd35 authored by Andrew Morgan's avatar Andrew Morgan Committed by Amber Brown
Browse files

Filter user directory state query to a subset of state events (#4462)

* Filter user directory state query to a subset of state events

* Add changelog
parent ef43a03f
Branches
Tags
No related merge requests found
Change the user directory state query to use a filtered call to the db instead of a generic one.
\ No newline at end of file
...@@ -22,6 +22,7 @@ from twisted.internet import defer ...@@ -22,6 +22,7 @@ from twisted.internet import defer
from synapse.api.constants import EventTypes, JoinRules from synapse.api.constants import EventTypes, JoinRules
from synapse.storage.engines import PostgresEngine, Sqlite3Engine from synapse.storage.engines import PostgresEngine, Sqlite3Engine
from synapse.storage.state import StateFilter
from synapse.types import get_domain_from_id, get_localpart_from_id from synapse.types import get_domain_from_id, get_localpart_from_id
from synapse.util.caches.descriptors import cached, cachedInlineCallbacks from synapse.util.caches.descriptors import cached, cachedInlineCallbacks
...@@ -31,12 +32,19 @@ logger = logging.getLogger(__name__) ...@@ -31,12 +32,19 @@ logger = logging.getLogger(__name__)
class UserDirectoryStore(SQLBaseStore): class UserDirectoryStore(SQLBaseStore):
@cachedInlineCallbacks(cache_context=True) @defer.inlineCallbacks
def is_room_world_readable_or_publicly_joinable(self, room_id, cache_context): def is_room_world_readable_or_publicly_joinable(self, room_id):
"""Check if the room is either world_readable or publically joinable """Check if the room is either world_readable or publically joinable
""" """
current_state_ids = yield self.get_current_state_ids(
room_id, on_invalidate=cache_context.invalidate # Create a state filter that only queries join and history state event
types_to_filter = (
(EventTypes.JoinRules, ""),
(EventTypes.RoomHistoryVisibility, ""),
)
current_state_ids = yield self.get_filtered_current_state_ids(
room_id, StateFilter.from_types(types_to_filter),
) )
join_rules_id = current_state_ids.get((EventTypes.JoinRules, "")) join_rules_id = current_state_ids.get((EventTypes.JoinRules, ""))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment