Use JSON instead of msgpack
parent
92c58932d1
commit
4c67e06dfb
|
@ -18,7 +18,7 @@ from synapse.api.errors import SynapseError
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from unpaddedbase64 import encode_base64, decode_base64
|
from unpaddedbase64 import encode_base64, decode_base64
|
||||||
import msgpack
|
import ujson as serializer
|
||||||
|
|
||||||
|
|
||||||
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 = msgpack.loads(decode_base64(string))
|
d = serializer.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(msgpack.dumps({
|
return encode_base64(serializer.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