diff options
author | Erik Johnston <erik@matrix.org> | 2020-02-07 13:56:38 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-07 13:56:38 +0000 |
commit | b08b0a22d505b1555f511e3f38935a62930ea25d (patch) | |
tree | 53cfe0c6c9d59e8d1b97affa473041692b056c96 /synapse/federation/units.py | |
parent | Allow moving group read APIs to workers (#6866) (diff) | |
download | synapse-b08b0a22d505b1555f511e3f38935a62930ea25d.tar.xz |
Add typing to synapse.federation.sender (#6871)
Diffstat (limited to 'synapse/federation/units.py')
-rw-r--r-- | synapse/federation/units.py | 23 |
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", "{}") |