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

Commit

Permalink
Remove state_group and entry arguments from `get_joined_users_fro…
Browse files Browse the repository at this point in the history
…m_state` methods
  • Loading branch information
Fizzadar committed Aug 25, 2022
1 parent f992ddf commit 5f99fe8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
2 changes: 1 addition & 1 deletion synapse/state/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ async def get_current_users_in_room(
logger.debug("calling resolve_state_groups from get_current_users_in_room")
entry = await self.resolve_state_groups_for_events(room_id, latest_event_ids)
state = await entry.get_state(self._state_storage_controller, StateFilter.all())
return await self.store.get_joined_users_from_state(room_id, state, entry)
return await self.store.get_joined_users_from_state(room_id, state)

async def get_hosts_in_room_at_events(
self, room_id: str, event_ids: Collection[str]
Expand Down
26 changes: 4 additions & 22 deletions synapse/storage/databases/main/roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,24 +835,13 @@ async def get_mutual_rooms_between_users(
return shared_room_ids or frozenset()

async def get_joined_users_from_state(
self, room_id: str, state: StateMap[str], state_entry: "_StateCacheEntry"
self, room_id: str, state: StateMap[str]
) -> Dict[str, ProfileInfo]:
state_group: Union[object, int] = state_entry.state_group
if not state_group:
# If state_group is None it means it has yet to be assigned a
# state group, i.e. we need to make sure that calls with a state_group
# of None don't hit previous cached calls with a None state_group.
# To do this we set the state_group to a new object as object() != object()
state_group = object()

assert state_group is not None
with Measure(self._clock, "get_joined_users_from_state"):
return await self._get_joined_users_from_context(state_group, state)
return await self._get_joined_users_from_context(state)

async def _get_joined_users_from_context(
self,
state_group: Union[object, int],
current_state_ids: StateMap[str],
self, current_state_ids: StateMap[str]
) -> Dict[str, ProfileInfo]:
"""
For a given state_group, get a map of user ID to profile information for users in the room.
Expand All @@ -862,11 +851,6 @@ async def _get_joined_users_from_context(
`_get_joined_profiles_from_event_ids` which does the actual data fetching.
"""

# We don't use `state_group`, it's there so that we can cache based
# on it. However, it's important that it's never None, since two current_states
# with a state_group of None are likely to be different.
assert state_group is not None

users_in_room = {}
member_event_ids = [
e_id
Expand Down Expand Up @@ -1104,9 +1088,7 @@ async def _get_joined_hosts(
else:
# The cache doesn't match the state group or prev state group,
# so we calculate the result from first principles.
joined_users = await self.get_joined_users_from_state(
room_id, state, state_entry
)
joined_users = await self.get_joined_users_from_state(room_id, state)

cache.hosts_to_joined_users = {}
for user_id in joined_users:
Expand Down

0 comments on commit 5f99fe8

Please sign in to comment.