Fix 'A next_batch token can be used in the v1 messages API'

erikj/paginate_sync
Erik Johnston 2016-06-16 11:33:53 +01:00
parent 2b0f9bddcf
commit 96d6fff447
2 changed files with 10 additions and 6 deletions

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
from synapse.api.errors import SynapseError from synapse.api.errors import SynapseError
from synapse.types import StreamToken from synapse.types import StreamToken, SyncNextBatchToken
import logging import logging
@ -72,14 +72,18 @@ class PaginationConfig(object):
if direction not in ['f', 'b']: if direction not in ['f', 'b']:
raise SynapseError(400, "'dir' parameter is invalid.") raise SynapseError(400, "'dir' parameter is invalid.")
from_tok = get_param("from") raw_from_tok = get_param("from")
to_tok = get_param("to") to_tok = get_param("to")
try: try:
if from_tok == "END": from_tok = None
if raw_from_tok == "END":
from_tok = None # For backwards compat. from_tok = None # For backwards compat.
elif from_tok: elif raw_from_tok:
from_tok = StreamToken.from_string(from_tok) try:
from_tok = SyncNextBatchToken.from_string(raw_from_tok).stream_token
except:
from_tok = StreamToken.from_string(raw_from_tok)
except: except:
raise SynapseError(400, "'from' paramater is invalid") raise SynapseError(400, "'from' paramater is invalid")

View File

@ -174,7 +174,7 @@ class SyncPaginationState(
class StreamToken( class StreamToken(
namedtuple("Token", ( namedtuple("StreamToken", (
"room_key", "room_key",
"presence_key", "presence_key",
"typing_key", "typing_key",