mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-09-21 20:24:34 -04:00
SYN-144: Remove bad keys from pdu json objects, convert age_ts to age
for all pdus sent.
This commit is contained in:
parent
572a1ca42a
commit
428581dd05
2 changed files with 29 additions and 15 deletions
|
@ -117,10 +117,21 @@ class SynapseEvent(JsonEncodedObject):
|
|||
"""
|
||||
raise NotImplementedError("get_content_template not implemented.")
|
||||
|
||||
def get_pdu_json(self):
|
||||
def get_pdu_json(self, time_now=None):
|
||||
pdu_json = self.get_full_dict()
|
||||
pdu_json.pop("destination", None)
|
||||
pdu_json.pop("outlier", None)
|
||||
pdu_json.pop("replaces_state", None)
|
||||
pdu_json.pop("redacted", None)
|
||||
state_hash = pdu_json.pop("state_hash", None)
|
||||
if state_hash is not None:
|
||||
pdu_json.setdefault("unsigned", {})["state_hash"] = state_hash
|
||||
content = pdu_json.get("content", {})
|
||||
content.pop("prev", None)
|
||||
if time_now is not None and "age_ts" in pdu_json:
|
||||
age = time_now - pdu_json["age_ts"]
|
||||
pdu_json.setdefault("unsigned", {})["age"] = int(age)
|
||||
del pdu_json["age_ts"]
|
||||
return pdu_json
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue