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

Limit the number of events that can be requested when backfilling events #6864

Merged
merged 2 commits into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6864.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Limit the number of events that can be requested by the backfill federation API to 100.
4 changes: 4 additions & 0 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,9 @@ def on_backfill_request(self, origin, room_id, pdu_list, limit):
if not in_room:
raise AuthError(403, "Host not in room.")

# Synapse asks for 100 events per backfill request. Do not allow more.
limit = min(limit, 100)

events = yield self.store.get_backfill_events(room_id, pdu_list, limit)

events = yield filter_events_for_server(self.storage, origin, events)
Expand Down Expand Up @@ -2169,6 +2172,7 @@ async def on_get_missing_events(
if not in_room:
raise AuthError(403, "Host not in room.")

# Only allow up to 20 events to be retrieved per request.
limit = min(limit, 20)

missing_events = await self.store.get_missing_events(
Expand Down