mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-18 00:43:30 +03:00
Sliding sync: factor out room list logic (#17622)
Move calculating of the room lists out of the core handler. This should make it easier to switch things around to start using the tables in #17512. This is just moving code between files and methods. Reviewable commit-by-commit
This commit is contained in:
parent
e75a23a63d
commit
689641b903
7 changed files with 1468 additions and 1356 deletions
1
changelog.d/17622.misc
Normal file
1
changelog.d/17622.misc
Normal file
|
@ -0,0 +1 @@
|
|||
Refactor sliding sync code to move room list logic out into a separate class.
|
File diff suppressed because it is too large
Load diff
|
@ -13,7 +13,7 @@
|
|||
#
|
||||
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Dict, List, Mapping, Optional, Sequence, Set
|
||||
from typing import TYPE_CHECKING, AbstractSet, Dict, Mapping, Optional, Sequence, Set
|
||||
|
||||
from typing_extensions import assert_never
|
||||
|
||||
|
@ -30,6 +30,7 @@ from synapse.types import (
|
|||
JsonMapping,
|
||||
MultiWriterStreamToken,
|
||||
SlidingSyncStreamToken,
|
||||
StrCollection,
|
||||
StreamToken,
|
||||
)
|
||||
from synapse.types.handlers import OperationType, SlidingSyncConfig, SlidingSyncResult
|
||||
|
@ -55,9 +56,9 @@ class SlidingSyncExtensionHandler:
|
|||
sync_config: SlidingSyncConfig,
|
||||
previous_connection_state: "PerConnectionState",
|
||||
new_connection_state: "MutablePerConnectionState",
|
||||
actual_lists: Dict[str, SlidingSyncResult.SlidingWindowList],
|
||||
actual_lists: Mapping[str, SlidingSyncResult.SlidingWindowList],
|
||||
actual_room_ids: Set[str],
|
||||
actual_room_response_map: Dict[str, SlidingSyncResult.RoomResult],
|
||||
actual_room_response_map: Mapping[str, SlidingSyncResult.RoomResult],
|
||||
to_token: StreamToken,
|
||||
from_token: Optional[SlidingSyncStreamToken],
|
||||
) -> SlidingSyncResult.Extensions:
|
||||
|
@ -144,10 +145,10 @@ class SlidingSyncExtensionHandler:
|
|||
|
||||
def find_relevant_room_ids_for_extension(
|
||||
self,
|
||||
requested_lists: Optional[List[str]],
|
||||
requested_room_ids: Optional[List[str]],
|
||||
actual_lists: Dict[str, SlidingSyncResult.SlidingWindowList],
|
||||
actual_room_ids: Set[str],
|
||||
requested_lists: Optional[StrCollection],
|
||||
requested_room_ids: Optional[StrCollection],
|
||||
actual_lists: Mapping[str, SlidingSyncResult.SlidingWindowList],
|
||||
actual_room_ids: AbstractSet[str],
|
||||
) -> Set[str]:
|
||||
"""
|
||||
Handle the reserved `lists`/`rooms` keys for extensions. Extensions should only
|
||||
|
@ -343,7 +344,7 @@ class SlidingSyncExtensionHandler:
|
|||
async def get_account_data_extension_response(
|
||||
self,
|
||||
sync_config: SlidingSyncConfig,
|
||||
actual_lists: Dict[str, SlidingSyncResult.SlidingWindowList],
|
||||
actual_lists: Mapping[str, SlidingSyncResult.SlidingWindowList],
|
||||
actual_room_ids: Set[str],
|
||||
account_data_request: SlidingSyncConfig.Extensions.AccountDataExtension,
|
||||
to_token: StreamToken,
|
||||
|
@ -436,9 +437,9 @@ class SlidingSyncExtensionHandler:
|
|||
sync_config: SlidingSyncConfig,
|
||||
previous_connection_state: "PerConnectionState",
|
||||
new_connection_state: "MutablePerConnectionState",
|
||||
actual_lists: Dict[str, SlidingSyncResult.SlidingWindowList],
|
||||
actual_lists: Mapping[str, SlidingSyncResult.SlidingWindowList],
|
||||
actual_room_ids: Set[str],
|
||||
actual_room_response_map: Dict[str, SlidingSyncResult.RoomResult],
|
||||
actual_room_response_map: Mapping[str, SlidingSyncResult.RoomResult],
|
||||
receipts_request: SlidingSyncConfig.Extensions.ReceiptsExtension,
|
||||
to_token: StreamToken,
|
||||
from_token: Optional[SlidingSyncStreamToken],
|
||||
|
@ -598,9 +599,9 @@ class SlidingSyncExtensionHandler:
|
|||
async def get_typing_extension_response(
|
||||
self,
|
||||
sync_config: SlidingSyncConfig,
|
||||
actual_lists: Dict[str, SlidingSyncResult.SlidingWindowList],
|
||||
actual_lists: Mapping[str, SlidingSyncResult.SlidingWindowList],
|
||||
actual_room_ids: Set[str],
|
||||
actual_room_response_map: Dict[str, SlidingSyncResult.RoomResult],
|
||||
actual_room_response_map: Mapping[str, SlidingSyncResult.RoomResult],
|
||||
typing_request: SlidingSyncConfig.Extensions.TypingExtension,
|
||||
to_token: StreamToken,
|
||||
from_token: Optional[SlidingSyncStreamToken],
|
||||
|
|
1353
synapse/handlers/sliding_sync/room_lists.py
Normal file
1353
synapse/handlers/sliding_sync/room_lists.py
Normal file
File diff suppressed because it is too large
Load diff
|
@ -21,7 +21,7 @@
|
|||
import itertools
|
||||
import logging
|
||||
from collections import defaultdict
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, Tuple, Union
|
||||
|
||||
from synapse.api.constants import AccountDataTypes, EduTypes, Membership, PresenceState
|
||||
from synapse.api.errors import Codes, StoreError, SynapseError
|
||||
|
@ -975,7 +975,7 @@ class SlidingSyncRestServlet(RestServlet):
|
|||
return response
|
||||
|
||||
def encode_lists(
|
||||
self, lists: Dict[str, SlidingSyncResult.SlidingWindowList]
|
||||
self, lists: Mapping[str, SlidingSyncResult.SlidingWindowList]
|
||||
) -> JsonDict:
|
||||
def encode_operation(
|
||||
operation: SlidingSyncResult.SlidingWindowList.Operation,
|
||||
|
|
|
@ -409,7 +409,7 @@ class SlidingSyncResult:
|
|||
)
|
||||
|
||||
next_pos: SlidingSyncStreamToken
|
||||
lists: Dict[str, SlidingWindowList]
|
||||
lists: Mapping[str, SlidingWindowList]
|
||||
rooms: Dict[str, RoomResult]
|
||||
extensions: Extensions
|
||||
|
||||
|
|
|
@ -620,7 +620,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
now_token = self.event_sources.get_current_token()
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=now_token,
|
||||
to_token=now_token,
|
||||
|
@ -647,7 +647,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
after_room_token = self.event_sources.get_current_token()
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_room_token,
|
||||
to_token=after_room_token,
|
||||
|
@ -682,7 +682,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
after_room_token = self.event_sources.get_current_token()
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=after_room_token,
|
||||
to_token=after_room_token,
|
||||
|
@ -756,7 +756,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
after_room_token = self.event_sources.get_current_token()
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_room_token,
|
||||
to_token=after_room_token,
|
||||
|
@ -828,7 +828,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
after_kick_token = self.event_sources.get_current_token()
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=after_kick_token,
|
||||
to_token=after_kick_token,
|
||||
|
@ -921,7 +921,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_room_forgets,
|
||||
to_token=before_room_forgets,
|
||||
|
@ -951,7 +951,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
after_room2_token = self.event_sources.get_current_token()
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=after_room1_token,
|
||||
to_token=after_room2_token,
|
||||
|
@ -1001,7 +1001,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
self.helper.join(room_id2, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -1041,7 +1041,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
leave_response = self.helper.leave(room_id1, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -1088,7 +1088,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
leave_response = self.helper.leave(room_id1, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=after_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -1152,7 +1152,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
leave_response = self.helper.leave(kick_room_id, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=after_kick_token,
|
||||
to_token=after_kick_token,
|
||||
|
@ -1208,7 +1208,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
leave_response2 = self.helper.leave(room_id1, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -1263,7 +1263,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
join_response2 = self.helper.join(room_id1, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -1322,7 +1322,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
self.helper.join(room_id2, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=None,
|
||||
to_token=after_room1_token,
|
||||
|
@ -1404,7 +1404,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
self.helper.join(room_id4, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=from_token,
|
||||
to_token=to_token,
|
||||
|
@ -1477,7 +1477,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
self.helper.leave(room_id1, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=after_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -1520,7 +1520,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
self.helper.join(room_id1, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=after_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -1570,7 +1570,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
leave_response3 = self.helper.leave(room_id1, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -1632,7 +1632,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
leave_response3 = self.helper.leave(room_id1, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=after_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -1691,7 +1691,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
leave_response = self.helper.leave(room_id1, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=after_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -1765,7 +1765,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -1830,7 +1830,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
after_change1_token = self.event_sources.get_current_token()
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=after_room1_token,
|
||||
to_token=after_change1_token,
|
||||
|
@ -1902,7 +1902,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=after_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -1984,7 +1984,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
self.helper.leave(room_id1, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -2052,7 +2052,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -2088,7 +2088,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
after_more_changes_token = self.event_sources.get_current_token()
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=after_room1_token,
|
||||
to_token=after_more_changes_token,
|
||||
|
@ -2153,7 +2153,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
after_room1_token = self.event_sources.get_current_token()
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_room1_token,
|
||||
to_token=after_room1_token,
|
||||
|
@ -2229,7 +2229,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
self.helper.leave(room_id3, user1_id, tok=user1_tok)
|
||||
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_room3_token,
|
||||
to_token=after_room3_token,
|
||||
|
@ -2365,7 +2365,7 @@ class GetRoomMembershipForUserAtToTokenTestCase(HomeserverTestCase):
|
|||
|
||||
# The function under test
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_reset_token,
|
||||
to_token=after_reset_token,
|
||||
|
@ -2579,7 +2579,7 @@ class GetRoomMembershipForUserAtToTokenShardTestCase(BaseMultiWorkerStreamTestCa
|
|||
|
||||
# The function under test
|
||||
room_id_results = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
UserID.from_string(user1_id),
|
||||
from_token=before_stuck_activity_token,
|
||||
to_token=stuck_activity_token,
|
||||
|
@ -2669,14 +2669,14 @@ class FilterRoomsRelevantForSyncTestCase(HomeserverTestCase):
|
|||
Get the rooms the user should be syncing with
|
||||
"""
|
||||
room_membership_for_user_map = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
user=user,
|
||||
from_token=from_token,
|
||||
to_token=to_token,
|
||||
)
|
||||
)
|
||||
filtered_sync_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms_relevant_for_sync(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms_relevant_for_sync(
|
||||
user=user,
|
||||
room_membership_for_user_map=room_membership_for_user_map,
|
||||
)
|
||||
|
@ -3030,14 +3030,14 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
Get the rooms the user should be syncing with
|
||||
"""
|
||||
room_membership_for_user_map = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
user=user,
|
||||
from_token=from_token,
|
||||
to_token=to_token,
|
||||
)
|
||||
)
|
||||
filtered_sync_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms_relevant_for_sync(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms_relevant_for_sync(
|
||||
user=user,
|
||||
room_membership_for_user_map=room_membership_for_user_map,
|
||||
)
|
||||
|
@ -3196,7 +3196,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_dm=True`
|
||||
truthy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3210,7 +3210,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_dm=False`
|
||||
falsy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3252,7 +3252,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_encrypted=True`
|
||||
truthy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3266,7 +3266,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_encrypted=False`
|
||||
falsy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3316,7 +3316,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_encrypted=True`
|
||||
truthy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3330,7 +3330,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_encrypted=False`
|
||||
falsy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3390,7 +3390,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_encrypted=True`
|
||||
truthy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3404,7 +3404,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_encrypted=False`
|
||||
falsy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3463,7 +3463,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_encrypted=True`
|
||||
truthy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3484,7 +3484,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_encrypted=False`
|
||||
falsy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3533,7 +3533,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_encrypted=True`
|
||||
truthy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3549,7 +3549,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_encrypted=False`
|
||||
falsy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3619,7 +3619,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_encrypted=True`
|
||||
truthy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3637,7 +3637,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_encrypted=False`
|
||||
falsy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3700,7 +3700,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_encrypted=True`
|
||||
truthy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3716,7 +3716,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_encrypted=False`
|
||||
falsy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3760,7 +3760,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_invite=True`
|
||||
truthy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3774,7 +3774,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try with `is_invite=False`
|
||||
falsy_filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3827,7 +3827,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding only normal rooms
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(room_types=[None]),
|
||||
|
@ -3839,7 +3839,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding only spaces
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(room_types=[RoomTypes.SPACE]),
|
||||
|
@ -3851,7 +3851,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding normal rooms and spaces
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3865,7 +3865,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding an arbitrary room type
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3918,7 +3918,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding *NOT* normal rooms
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(not_room_types=[None]),
|
||||
|
@ -3930,7 +3930,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding *NOT* spaces
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3944,7 +3944,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding *NOT* normal rooms or spaces
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3959,7 +3959,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
# Test how it behaves when we have both `room_types` and `not_room_types`.
|
||||
# `not_room_types` should win.
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -3975,7 +3975,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
# Test how it behaves when we have both `room_types` and `not_room_types`.
|
||||
# `not_room_types` should win.
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(
|
||||
|
@ -4025,7 +4025,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding only normal rooms
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(room_types=[None]),
|
||||
|
@ -4037,7 +4037,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding only spaces
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(room_types=[RoomTypes.SPACE]),
|
||||
|
@ -4094,7 +4094,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding only normal rooms
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(room_types=[None]),
|
||||
|
@ -4106,7 +4106,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding only spaces
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(room_types=[RoomTypes.SPACE]),
|
||||
|
@ -4152,7 +4152,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding only normal rooms
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(room_types=[None]),
|
||||
|
@ -4166,7 +4166,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding only spaces
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(room_types=[RoomTypes.SPACE]),
|
||||
|
@ -4228,7 +4228,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding only normal rooms
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(room_types=[None]),
|
||||
|
@ -4242,7 +4242,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding only spaces
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(room_types=[RoomTypes.SPACE]),
|
||||
|
@ -4305,7 +4305,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding only normal rooms
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(room_types=[None]),
|
||||
|
@ -4319,7 +4319,7 @@ class FilterRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Try finding only spaces
|
||||
filtered_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms(
|
||||
UserID.from_string(user1_id),
|
||||
sync_room_map,
|
||||
SlidingSyncConfig.SlidingSyncList.Filters(room_types=[RoomTypes.SPACE]),
|
||||
|
@ -4366,14 +4366,14 @@ class SortRoomsTestCase(HomeserverTestCase):
|
|||
Get the rooms the user should be syncing with
|
||||
"""
|
||||
room_membership_for_user_map = self.get_success(
|
||||
self.sliding_sync_handler.get_room_membership_for_user_at_to_token(
|
||||
self.sliding_sync_handler.room_lists.get_room_membership_for_user_at_to_token(
|
||||
user=user,
|
||||
from_token=from_token,
|
||||
to_token=to_token,
|
||||
)
|
||||
)
|
||||
filtered_sync_room_map = self.get_success(
|
||||
self.sliding_sync_handler.filter_rooms_relevant_for_sync(
|
||||
self.sliding_sync_handler.room_lists.filter_rooms_relevant_for_sync(
|
||||
user=user,
|
||||
room_membership_for_user_map=room_membership_for_user_map,
|
||||
)
|
||||
|
@ -4408,7 +4408,7 @@ class SortRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Sort the rooms (what we're testing)
|
||||
sorted_sync_rooms = self.get_success(
|
||||
self.sliding_sync_handler.sort_rooms(
|
||||
self.sliding_sync_handler.room_lists.sort_rooms(
|
||||
sync_room_map=sync_room_map,
|
||||
to_token=after_rooms_token,
|
||||
)
|
||||
|
@ -4489,7 +4489,7 @@ class SortRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Sort the rooms (what we're testing)
|
||||
sorted_sync_rooms = self.get_success(
|
||||
self.sliding_sync_handler.sort_rooms(
|
||||
self.sliding_sync_handler.room_lists.sort_rooms(
|
||||
sync_room_map=sync_room_map,
|
||||
to_token=after_rooms_token,
|
||||
)
|
||||
|
@ -4553,7 +4553,7 @@ class SortRoomsTestCase(HomeserverTestCase):
|
|||
|
||||
# Sort the rooms (what we're testing)
|
||||
sorted_sync_rooms = self.get_success(
|
||||
self.sliding_sync_handler.sort_rooms(
|
||||
self.sliding_sync_handler.room_lists.sort_rooms(
|
||||
sync_room_map=sync_room_map,
|
||||
to_token=after_rooms_token,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue