From 96d6fff44787a53863b1321ed28f1636aa5dc78a Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 16 Jun 2016 11:33:53 +0100 Subject: Fix 'A next_batch token can be used in the v1 messages API' --- synapse/streams/config.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'synapse/streams/config.py') diff --git a/synapse/streams/config.py b/synapse/streams/config.py index 4f089bfb94..49be3c222a 100644 --- a/synapse/streams/config.py +++ b/synapse/streams/config.py @@ -14,7 +14,7 @@ # limitations under the License. from synapse.api.errors import SynapseError -from synapse.types import StreamToken +from synapse.types import StreamToken, SyncNextBatchToken import logging @@ -72,14 +72,18 @@ class PaginationConfig(object): if direction not in ['f', 'b']: raise SynapseError(400, "'dir' parameter is invalid.") - from_tok = get_param("from") + raw_from_tok = get_param("from") to_tok = get_param("to") try: - if from_tok == "END": + from_tok = None + if raw_from_tok == "END": from_tok = None # For backwards compat. - elif from_tok: - from_tok = StreamToken.from_string(from_tok) + elif raw_from_tok: + try: + from_tok = SyncNextBatchToken.from_string(raw_from_tok).stream_token + except: + from_tok = StreamToken.from_string(raw_from_tok) except: raise SynapseError(400, "'from' paramater is invalid") -- cgit 1.5.1