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

Tie together matches_user_in_member_list and get_users_in_room caches #8676

Merged
merged 6 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions changelog.d/8676.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug where an appservice may not be forwarded events for a room it was recently invited to. Broken in v1.22.0.
10 changes: 6 additions & 4 deletions synapse/appservice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from synapse.api.constants import EventTypes
from synapse.events import EventBase
from synapse.types import GroupID, JsonDict, UserID, get_domain_from_id
from synapse.util.caches.descriptors import cached
from synapse.util.caches.descriptors import _CacheContext, cached

if TYPE_CHECKING:
from synapse.appservice.api import ApplicationServiceApi
Expand Down Expand Up @@ -164,9 +164,9 @@ async def _matches_user(
does_match = await self.matches_user_in_member_list(event.room_id, store)
return does_match

@cached(num_args=1)
@cached(num_args=1, cache_context=True)
async def matches_user_in_member_list(
self, room_id: str, store: "DataStore"
self, room_id: str, store: "DataStore", cache_context: _CacheContext,
) -> bool:
"""Check if this service is interested a room based upon it's membership

Expand All @@ -177,7 +177,9 @@ async def matches_user_in_member_list(
Returns:
True if this service would like to know about this room.
"""
member_list = await store.get_users_in_room(room_id)
member_list = await store.get_users_in_room(
room_id, on_invalidate=cache_context.invalidate
)

# check joined member events
for user_id in member_list:
Expand Down