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

Commit 70269fb

Browse files
authored
Tie together matches_user_in_member_list and get_users_in_room caches (#8676)
* Tie together matches_user_in_member_list and get_users_in_room * changelog * Remove type to fix mypy * Add `on_invalidate` to the function signature in the hopes that may make things work well * Remove **kwargs * Update 8676.bugfix
1 parent 8b42a4e commit 70269fb

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

changelog.d/8676.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

synapse/appservice/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from synapse.api.constants import EventTypes
2020
from synapse.events import EventBase
2121
from synapse.types import GroupID, JsonDict, UserID, get_domain_from_id
22-
from synapse.util.caches.descriptors import cached
22+
from synapse.util.caches.descriptors import _CacheContext, cached
2323

2424
if TYPE_CHECKING:
2525
from synapse.appservice.api import ApplicationServiceApi
@@ -164,9 +164,9 @@ async def _matches_user(
164164
does_match = await self.matches_user_in_member_list(event.room_id, store)
165165
return does_match
166166

167-
@cached(num_args=1)
167+
@cached(num_args=1, cache_context=True)
168168
async def matches_user_in_member_list(
169-
self, room_id: str, store: "DataStore"
169+
self, room_id: str, store: "DataStore", cache_context: _CacheContext,
170170
) -> bool:
171171
"""Check if this service is interested a room based upon it's membership
172172
@@ -177,7 +177,9 @@ async def matches_user_in_member_list(
177177
Returns:
178178
True if this service would like to know about this room.
179179
"""
180-
member_list = await store.get_users_in_room(room_id)
180+
member_list = await store.get_users_in_room(
181+
room_id, on_invalidate=cache_context.invalidate
182+
)
181183

182184
# check joined member events
183185
for user_id in member_list:

0 commit comments

Comments
 (0)