Use msgpack for shorter tokens
parent
3b6027dbc1
commit
cdd379b6df
|
@ -36,6 +36,7 @@ REQUIREMENTS = {
|
||||||
"blist": ["blist"],
|
"blist": ["blist"],
|
||||||
"pysaml2>=3.0.0,<4.0.0": ["saml2>=3.0.0,<4.0.0"],
|
"pysaml2>=3.0.0,<4.0.0": ["saml2>=3.0.0,<4.0.0"],
|
||||||
"pymacaroons-pynacl": ["pymacaroons"],
|
"pymacaroons-pynacl": ["pymacaroons"],
|
||||||
|
"msgpack": ["msgpack"],
|
||||||
}
|
}
|
||||||
CONDITIONAL_REQUIREMENTS = {
|
CONDITIONAL_REQUIREMENTS = {
|
||||||
"web_client": {
|
"web_client": {
|
||||||
|
|
|
@ -19,7 +19,7 @@ from collections import namedtuple
|
||||||
|
|
||||||
from unpaddedbase64 import encode_base64, decode_base64
|
from unpaddedbase64 import encode_base64, decode_base64
|
||||||
import ujson as json
|
import ujson as json
|
||||||
|
import msgpack
|
||||||
|
|
||||||
Requester = namedtuple("Requester", ["user", "access_token_id", "is_guest"])
|
Requester = namedtuple("Requester", ["user", "access_token_id", "is_guest"])
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ class SyncNextBatchToken(
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_string(cls, string):
|
def from_string(cls, string):
|
||||||
try:
|
try:
|
||||||
d = json.loads(decode_base64(string))
|
d = msgpack.loads(decode_base64(string))
|
||||||
pa = d.get("pa", None)
|
pa = d.get("pa", None)
|
||||||
if pa:
|
if pa:
|
||||||
pa = SyncPaginationState.from_dict(pa)
|
pa = SyncPaginationState.from_dict(pa)
|
||||||
|
@ -139,7 +139,7 @@ class SyncNextBatchToken(
|
||||||
raise SynapseError(400, "Invalid Token")
|
raise SynapseError(400, "Invalid Token")
|
||||||
|
|
||||||
def to_string(self):
|
def to_string(self):
|
||||||
return encode_base64(json.dumps({
|
return encode_base64(msgpack.dumps({
|
||||||
"t": self.stream_token.to_arr(),
|
"t": self.stream_token.to_arr(),
|
||||||
"pa": self.pagination_state.to_dict() if self.pagination_state else None,
|
"pa": self.pagination_state.to_dict() if self.pagination_state else None,
|
||||||
}))
|
}))
|
||||||
|
|
Loading…
Reference in New Issue