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

Clamp pagination limits to at most 1000 #497

Merged
merged 1 commit into from
Jan 14, 2016
Merged
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
7 changes: 5 additions & 2 deletions synapse/streams/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
logger = logging.getLogger(__name__)


MAX_LIMIT = 1000


class SourcePaginationConfig(object):

"""A configuration object which stores pagination parameters for a
Expand All @@ -32,7 +35,7 @@ def __init__(self, from_key=None, to_key=None, direction='f',
self.from_key = from_key
self.to_key = to_key
self.direction = 'f' if direction == 'f' else 'b'
self.limit = int(limit) if limit is not None else None
self.limit = min(int(limit), MAX_LIMIT) if limit is not None else None

def __repr__(self):
return (
Expand All @@ -49,7 +52,7 @@ def __init__(self, from_token=None, to_token=None, direction='f',
self.from_token = from_token
self.to_token = to_token
self.direction = 'f' if direction == 'f' else 'b'
self.limit = int(limit) if limit is not None else None
self.limit = min(int(limit), MAX_LIMIT) if limit is not None else None

@classmethod
def from_request(cls, request, raise_invalid_params=True,
Expand Down