summary refs log tree commit diff
path: root/synapse/federation/units.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2020-02-18 15:50:06 +0000
committerErik Johnston <erik@matrix.org>2020-02-18 16:11:26 +0000
commitbc936b56572aef4fc16fffaa44a75bfdf99eeec4 (patch)
tree8c4c030157dd4fa9df5a1d04dac76486327f9d7e /synapse/federation/units.py
parentMerge branch 'release-v1.10.0' into matrix-org-hotfixes (diff)
parentIncrease perf of `get_auth_chain_ids` used in state res v2. (#6937) (diff)
downloadsynapse-bc936b56572aef4fc16fffaa44a75bfdf99eeec4.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into matrix-org-hotfixes
Diffstat (limited to 'synapse/federation/units.py')
-rw-r--r--synapse/federation/units.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/synapse/federation/units.py b/synapse/federation/units.py

index b4d743cde7..6b32e0dcbf 100644 --- a/synapse/federation/units.py +++ b/synapse/federation/units.py
@@ -19,11 +19,15 @@ server protocol. import logging +import attr + +from synapse.types import JsonDict from synapse.util.jsonobject import JsonEncodedObject logger = logging.getLogger(__name__) +@attr.s(slots=True) class Edu(JsonEncodedObject): """ An Edu represents a piece of data sent from one homeserver to another. @@ -32,11 +36,24 @@ class Edu(JsonEncodedObject): internal ID or previous references graph. """ - valid_keys = ["origin", "destination", "edu_type", "content"] + edu_type = attr.ib(type=str) + content = attr.ib(type=dict) + origin = attr.ib(type=str) + destination = attr.ib(type=str) - required_keys = ["edu_type"] + def get_dict(self) -> JsonDict: + return { + "edu_type": self.edu_type, + "content": self.content, + } - internal_keys = ["origin", "destination"] + def get_internal_dict(self) -> JsonDict: + return { + "edu_type": self.edu_type, + "content": self.content, + "origin": self.origin, + "destination": self.destination, + } def get_context(self): return getattr(self, "content", {}).get("org.matrix.opentracing_context", "{}")