mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-20 02:24:54 +03:00
Add fast path for sliding sync streams that only ask for extensions
Principally useful for EX e2ee sliding sync connections.
This commit is contained in:
parent
ef9ef99f59
commit
706bfbbb88
2 changed files with 22 additions and 0 deletions
|
@ -26,6 +26,7 @@ from synapse.handlers.relations import BundledAggregations
|
||||||
from synapse.handlers.sliding_sync.extensions import SlidingSyncExtensionHandler
|
from synapse.handlers.sliding_sync.extensions import SlidingSyncExtensionHandler
|
||||||
from synapse.handlers.sliding_sync.room_lists import (
|
from synapse.handlers.sliding_sync.room_lists import (
|
||||||
RoomsForUserType,
|
RoomsForUserType,
|
||||||
|
SlidingSyncInterestedRooms,
|
||||||
SlidingSyncRoomLists,
|
SlidingSyncRoomLists,
|
||||||
)
|
)
|
||||||
from synapse.handlers.sliding_sync.store import SlidingSyncConnectionStore
|
from synapse.handlers.sliding_sync.store import SlidingSyncConnectionStore
|
||||||
|
|
|
@ -123,6 +123,19 @@ class SlidingSyncInterestedRooms:
|
||||||
newly_left_rooms: AbstractSet[str]
|
newly_left_rooms: AbstractSet[str]
|
||||||
dm_room_ids: AbstractSet[str]
|
dm_room_ids: AbstractSet[str]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def empty() -> "SlidingSyncInterestedRooms":
|
||||||
|
return SlidingSyncInterestedRooms(
|
||||||
|
lists={},
|
||||||
|
relevant_room_map={},
|
||||||
|
relevant_rooms_to_send_map={},
|
||||||
|
all_rooms=set(),
|
||||||
|
room_membership_for_user_map={},
|
||||||
|
newly_joined_rooms=set(),
|
||||||
|
newly_left_rooms=set(),
|
||||||
|
dm_room_ids=set(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def filter_membership_for_sync(
|
def filter_membership_for_sync(
|
||||||
*,
|
*,
|
||||||
|
@ -181,6 +194,14 @@ class SlidingSyncRoomLists:
|
||||||
from_token: Optional[StreamToken],
|
from_token: Optional[StreamToken],
|
||||||
) -> SlidingSyncInterestedRooms:
|
) -> SlidingSyncInterestedRooms:
|
||||||
"""Fetch the set of rooms that match the request"""
|
"""Fetch the set of rooms that match the request"""
|
||||||
|
has_lists = sync_config.lists is not None and len(sync_config.lists) > 0
|
||||||
|
has_room_subscriptions = (
|
||||||
|
sync_config.room_subscriptions is not None
|
||||||
|
and len(sync_config.room_subscriptions) > 0
|
||||||
|
)
|
||||||
|
|
||||||
|
if not has_lists and not has_room_subscriptions:
|
||||||
|
return SlidingSyncInterestedRooms.empty()
|
||||||
|
|
||||||
if await self.store.have_finished_sliding_sync_background_jobs():
|
if await self.store.have_finished_sliding_sync_background_jobs():
|
||||||
return await self._compute_interested_rooms_new_tables(
|
return await self._compute_interested_rooms_new_tables(
|
||||||
|
|
Loading…
Reference in a new issue