mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-05 04:15:03 -04:00
Do not allow a None-limit on PaginationConfig. (#14146)
The callers either set a default limit or manually handle a None-limit later on (by setting a default value). Update the callers to always instantiate PaginationConfig with a default limit and then assume the limit is non-None.
This commit is contained in:
parent
c7446906bd
commit
126a15794c
16 changed files with 29 additions and 50 deletions
|
@ -57,13 +57,7 @@ class InitialSyncHandler:
|
|||
self.validator = EventValidator()
|
||||
self.snapshot_cache: ResponseCache[
|
||||
Tuple[
|
||||
str,
|
||||
Optional[StreamToken],
|
||||
Optional[StreamToken],
|
||||
str,
|
||||
Optional[int],
|
||||
bool,
|
||||
bool,
|
||||
str, Optional[StreamToken], Optional[StreamToken], str, int, bool, bool
|
||||
]
|
||||
] = ResponseCache(hs.get_clock(), "initial_sync_cache")
|
||||
self._event_serializer = hs.get_event_client_serializer()
|
||||
|
@ -154,11 +148,6 @@ class InitialSyncHandler:
|
|||
|
||||
public_room_ids = await self.store.get_public_room_ids()
|
||||
|
||||
if pagin_config.limit is not None:
|
||||
limit = pagin_config.limit
|
||||
else:
|
||||
limit = 10
|
||||
|
||||
serializer_options = SerializeEventConfig(as_client_event=as_client_event)
|
||||
|
||||
async def handle_room(event: RoomsForUser) -> None:
|
||||
|
@ -210,7 +199,7 @@ class InitialSyncHandler:
|
|||
run_in_background(
|
||||
self.store.get_recent_events_for_room,
|
||||
event.room_id,
|
||||
limit=limit,
|
||||
limit=pagin_config.limit,
|
||||
end_token=room_end_token,
|
||||
),
|
||||
deferred_room_state,
|
||||
|
@ -360,15 +349,11 @@ class InitialSyncHandler:
|
|||
member_event_id
|
||||
)
|
||||
|
||||
limit = pagin_config.limit if pagin_config else None
|
||||
if limit is None:
|
||||
limit = 10
|
||||
|
||||
leave_position = await self.store.get_position_for_event(member_event_id)
|
||||
stream_token = leave_position.to_room_stream_token()
|
||||
|
||||
messages, token = await self.store.get_recent_events_for_room(
|
||||
room_id, limit=limit, end_token=stream_token
|
||||
room_id, limit=pagin_config.limit, end_token=stream_token
|
||||
)
|
||||
|
||||
messages = await filter_events_for_client(
|
||||
|
@ -420,10 +405,6 @@ class InitialSyncHandler:
|
|||
|
||||
now_token = self.hs.get_event_sources().get_current_token()
|
||||
|
||||
limit = pagin_config.limit if pagin_config else None
|
||||
if limit is None:
|
||||
limit = 10
|
||||
|
||||
room_members = [
|
||||
m
|
||||
for m in current_state.values()
|
||||
|
@ -467,7 +448,7 @@ class InitialSyncHandler:
|
|||
run_in_background(
|
||||
self.store.get_recent_events_for_room,
|
||||
room_id,
|
||||
limit=limit,
|
||||
limit=pagin_config.limit,
|
||||
end_token=now_token.room_key,
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue