mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
SYN-58: Allow passing explicit limit=0 to initialSync to request no messages at all; missing still implies default 10
This commit is contained in:
parent
610c2ea131
commit
5f19c55731
@ -243,7 +243,7 @@ class MessageHandler(BaseHandler):
|
|||||||
public_room_ids = [r["room_id"] for r in public_rooms]
|
public_room_ids = [r["room_id"] for r in public_rooms]
|
||||||
|
|
||||||
limit = pagin_config.limit
|
limit = pagin_config.limit
|
||||||
if not limit:
|
if limit is None:
|
||||||
limit = 10
|
limit = 10
|
||||||
|
|
||||||
for event in room_list:
|
for event in room_list:
|
||||||
|
@ -28,11 +28,11 @@ class SourcePaginationConfig(object):
|
|||||||
specific event source."""
|
specific event source."""
|
||||||
|
|
||||||
def __init__(self, from_key=None, to_key=None, direction='f',
|
def __init__(self, from_key=None, to_key=None, direction='f',
|
||||||
limit=0):
|
limit=None):
|
||||||
self.from_key = from_key
|
self.from_key = from_key
|
||||||
self.to_key = to_key
|
self.to_key = to_key
|
||||||
self.direction = 'f' if direction == 'f' else 'b'
|
self.direction = 'f' if direction == 'f' else 'b'
|
||||||
self.limit = int(limit)
|
self.limit = int(limit) if limit is not None else None
|
||||||
|
|
||||||
|
|
||||||
class PaginationConfig(object):
|
class PaginationConfig(object):
|
||||||
@ -40,11 +40,11 @@ class PaginationConfig(object):
|
|||||||
"""A configuration object which stores pagination parameters."""
|
"""A configuration object which stores pagination parameters."""
|
||||||
|
|
||||||
def __init__(self, from_token=None, to_token=None, direction='f',
|
def __init__(self, from_token=None, to_token=None, direction='f',
|
||||||
limit=0):
|
limit=None):
|
||||||
self.from_token = from_token
|
self.from_token = from_token
|
||||||
self.to_token = to_token
|
self.to_token = to_token
|
||||||
self.direction = 'f' if direction == 'f' else 'b'
|
self.direction = 'f' if direction == 'f' else 'b'
|
||||||
self.limit = int(limit)
|
self.limit = int(limit) if limit is not None else None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_request(cls, request, raise_invalid_params=True):
|
def from_request(cls, request, raise_invalid_params=True):
|
||||||
@ -80,8 +80,8 @@ class PaginationConfig(object):
|
|||||||
except:
|
except:
|
||||||
raise SynapseError(400, "'to' paramater is invalid")
|
raise SynapseError(400, "'to' paramater is invalid")
|
||||||
|
|
||||||
limit = get_param("limit", "0")
|
limit = get_param("limit", None)
|
||||||
if not limit.isdigit():
|
if limit is not None and not limit.isdigit():
|
||||||
raise SynapseError(400, "'limit' parameter must be an integer.")
|
raise SynapseError(400, "'limit' parameter must be an integer.")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user