mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-26 19:47:05 +03:00
Avoid hardcoding names of individual stream token keys in its own implementation; this at least reduces the number of places in source code the individual parts are stored
This commit is contained in:
parent
95cbd026cc
commit
f85a3757cf
1 changed files with 3 additions and 9 deletions
|
@ -105,20 +105,14 @@ class StreamToken(
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_string(cls, string):
|
def from_string(cls, string):
|
||||||
try:
|
try:
|
||||||
events_key, presence_key = string.split(cls._SEPARATOR)
|
keys = string.split(cls._SEPARATOR)
|
||||||
|
|
||||||
return cls(
|
return cls(*keys)
|
||||||
events_key=events_key,
|
|
||||||
presence_key=presence_key,
|
|
||||||
)
|
|
||||||
except:
|
except:
|
||||||
raise SynapseError(400, "Invalid Token")
|
raise SynapseError(400, "Invalid Token")
|
||||||
|
|
||||||
def to_string(self):
|
def to_string(self):
|
||||||
return self._SEPARATOR.join([
|
return self._SEPARATOR.join([str(k) for k in self])
|
||||||
str(self.events_key),
|
|
||||||
str(self.presence_key),
|
|
||||||
])
|
|
||||||
|
|
||||||
def copy_and_replace(self, key, new_value):
|
def copy_and_replace(self, key, new_value):
|
||||||
d = self._asdict()
|
d = self._asdict()
|
||||||
|
|
Loading…
Reference in a new issue