Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Feb 5, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+13 −4
Diff settings

Always

Just for now

Copy path View file
@@ -0,0 +1 @@
Change the user directory state query to use a filtered call to the db instead of a generic one.

This comment has been minimized.

Copy link
@anoadragon453

anoadragon453 Jan 25, 2019

Author Member

Hm, is a changelog even worth it for this change?

This comment has been minimized.

Copy link
@hawkowl

hawkowl Jan 29, 2019

Contributor

yes, every change needs a changelog.

@@ -22,6 +22,7 @@

from synapse.api.constants import EventTypes, JoinRules
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.util.caches.descriptors import cached, cachedInlineCallbacks

@@ -31,12 +32,19 @@


class UserDirectoryStore(SQLBaseStore):
@cachedInlineCallbacks(cache_context=True)
def is_room_world_readable_or_publicly_joinable(self, room_id, cache_context):
@defer.inlineCallbacks
def is_room_world_readable_or_publicly_joinable(self, room_id):
"""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, ""))
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.