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

This commit is contained in:
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.
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")

View file

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