mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Fix forgotten rooms missing in initial sync (#15815)
If you leave a room and forget it, then rejoin it, the room would be missing from the next initial sync. fixes #13262 Signed-off-by: Nicolas Werner <n.werner@famedly.com>
This commit is contained in:
parent
289ce3b8d9
commit
e0c39d6bb5
1
changelog.d/15815.bugfix
Normal file
1
changelog.d/15815.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix forgotten rooms missing from initial sync after rejoining them. Contributed by Nico from Famedly.
|
@ -289,6 +289,17 @@ class CacheInvalidationWorkerStore(SQLBaseStore):
|
|||||||
)
|
)
|
||||||
self._attempt_to_invalidate_cache("get_rooms_for_user", (state_key,))
|
self._attempt_to_invalidate_cache("get_rooms_for_user", (state_key,))
|
||||||
|
|
||||||
|
self._attempt_to_invalidate_cache(
|
||||||
|
"did_forget",
|
||||||
|
(
|
||||||
|
state_key,
|
||||||
|
room_id,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
self._attempt_to_invalidate_cache(
|
||||||
|
"get_forgotten_rooms_for_user", (state_key,)
|
||||||
|
)
|
||||||
|
|
||||||
if relates_to:
|
if relates_to:
|
||||||
self._attempt_to_invalidate_cache("get_relations_for_event", (relates_to,))
|
self._attempt_to_invalidate_cache("get_relations_for_event", (relates_to,))
|
||||||
self._attempt_to_invalidate_cache("get_references_for_event", (relates_to,))
|
self._attempt_to_invalidate_cache("get_references_for_event", (relates_to,))
|
||||||
@ -336,6 +347,8 @@ class CacheInvalidationWorkerStore(SQLBaseStore):
|
|||||||
"get_rooms_for_user_with_stream_ordering", None
|
"get_rooms_for_user_with_stream_ordering", None
|
||||||
)
|
)
|
||||||
self._attempt_to_invalidate_cache("get_rooms_for_user", None)
|
self._attempt_to_invalidate_cache("get_rooms_for_user", None)
|
||||||
|
self._attempt_to_invalidate_cache("did_forget", None)
|
||||||
|
self._attempt_to_invalidate_cache("get_forgotten_rooms_for_user", None)
|
||||||
self._attempt_to_invalidate_cache("get_references_for_event", None)
|
self._attempt_to_invalidate_cache("get_references_for_event", None)
|
||||||
self._attempt_to_invalidate_cache("get_thread_summary", None)
|
self._attempt_to_invalidate_cache("get_thread_summary", None)
|
||||||
self._attempt_to_invalidate_cache("get_thread_participated", None)
|
self._attempt_to_invalidate_cache("get_thread_participated", None)
|
||||||
|
@ -333,6 +333,27 @@ class RoomMemberMasterHandlerTestCase(HomeserverTestCase):
|
|||||||
self.get_success(self.store.is_locally_forgotten_room(self.room_id))
|
self.get_success(self.store.is_locally_forgotten_room(self.room_id))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_leave_and_unforget(self) -> None:
|
||||||
|
"""Tests if rejoining a room unforgets the room, so that it shows up in sync again."""
|
||||||
|
self.helper.join(self.room_id, user=self.bob, tok=self.bob_token)
|
||||||
|
|
||||||
|
# alice is not the last room member that leaves and forgets the room
|
||||||
|
self.helper.leave(self.room_id, user=self.alice, tok=self.alice_token)
|
||||||
|
self.get_success(self.handler.forget(self.alice_ID, self.room_id))
|
||||||
|
self.assertTrue(
|
||||||
|
self.get_success(self.store.did_forget(self.alice, self.room_id))
|
||||||
|
)
|
||||||
|
|
||||||
|
self.helper.join(self.room_id, user=self.alice, tok=self.alice_token)
|
||||||
|
self.assertFalse(
|
||||||
|
self.get_success(self.store.did_forget(self.alice, self.room_id))
|
||||||
|
)
|
||||||
|
|
||||||
|
# the server has not forgotten the room
|
||||||
|
self.assertFalse(
|
||||||
|
self.get_success(self.store.is_locally_forgotten_room(self.room_id))
|
||||||
|
)
|
||||||
|
|
||||||
@override_config({"forget_rooms_on_leave": True})
|
@override_config({"forget_rooms_on_leave": True})
|
||||||
def test_leave_and_auto_forget(self) -> None:
|
def test_leave_and_auto_forget(self) -> None:
|
||||||
"""Tests the `forget_rooms_on_leave` config option."""
|
"""Tests the `forget_rooms_on_leave` config option."""
|
||||||
|
Loading…
Reference in New Issue
Block a user