summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-06-21 11:36:28 +0100
committerErik Johnston <erik@matrix.org>2016-06-21 11:36:28 +0100
commitcdd379b6df4f9eb3cbfaae2b576538d3d23d38d6 (patch)
treef2d23407520bceecc8b36d59da0368dac4e0b980
parentAlways include tags (diff)
downloadsynapse-cdd379b6df4f9eb3cbfaae2b576538d3d23d38d6.tar.xz
Use msgpack for shorter tokens
-rw-r--r--synapse/python_dependencies.py1
-rw-r--r--synapse/types.py6
2 files changed, 4 insertions, 3 deletions
diff --git a/synapse/python_dependencies.py b/synapse/python_dependencies.py

index e0a7a19777..ca49645e90 100644 --- a/synapse/python_dependencies.py +++ b/synapse/python_dependencies.py
@@ -36,6 +36,7 @@ REQUIREMENTS = { "blist": ["blist"], "pysaml2>=3.0.0,<4.0.0": ["saml2>=3.0.0,<4.0.0"], "pymacaroons-pynacl": ["pymacaroons"], + "msgpack": ["msgpack"], } CONDITIONAL_REQUIREMENTS = { "web_client": { diff --git a/synapse/types.py b/synapse/types.py
index 13cdc737fb..e4eddbacef 100644 --- a/synapse/types.py +++ b/synapse/types.py
@@ -19,7 +19,7 @@ from collections import namedtuple from unpaddedbase64 import encode_base64, decode_base64 import ujson as json - +import msgpack Requester = namedtuple("Requester", ["user", "access_token_id", "is_guest"]) @@ -127,7 +127,7 @@ class SyncNextBatchToken( @classmethod def from_string(cls, string): try: - d = json.loads(decode_base64(string)) + d = msgpack.loads(decode_base64(string)) pa = d.get("pa", None) if pa: pa = SyncPaginationState.from_dict(pa) @@ -139,7 +139,7 @@ class SyncNextBatchToken( raise SynapseError(400, "Invalid Token") def to_string(self): - return encode_base64(json.dumps({ + return encode_base64(msgpack.dumps({ "t": self.stream_token.to_arr(), "pa": self.pagination_state.to_dict() if self.pagination_state else None, }))