diff options
author | Erik Johnston <erik@matrix.org> | 2021-05-05 13:52:41 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2021-05-05 15:06:27 +0100 |
commit | 3d937d23fdbe29b6f5939403a238521641a78ec8 (patch) | |
tree | 0210542b5a9981a1e39010f42acba2d021cbe0b9 | |
parent | Remvoe dictionary based access form events (diff) | |
download | synapse-3d937d23fdbe29b6f5939403a238521641a78ec8.tar.xz |
Don't use DictProperty
-rw-r--r-- | synapse/events/__init__.py | 29 | ||||
-rw-r--r-- | synapse/handlers/message.py | 4 |
2 files changed, 17 insertions, 16 deletions
diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py index 46d26e0af9..7a598a8193 100644 --- a/synapse/events/__init__.py +++ b/synapse/events/__init__.py @@ -230,21 +230,22 @@ class EventBase(metaclass=abc.ABCMeta): self._dict = event_dict - self.internal_metadata = _EventInternalMetadata(internal_metadata_dict) + self.auth_events = event_dict["auth_events"] + self.depth = event_dict["depth"] + self.content = event_dict["content"] + self.hashes = event_dict["hashes"] + self.origin = event_dict["origin"] + self.origin_server_ts = event_dict["origin_server_ts"] + self.prev_events = event_dict["prev_events"] + self.redacts = event_dict.get("redacts") + self.room_id = event_dict["room_id"] + self.sender = event_dict["sender"] + self.type = event_dict["type"] + self.user_id = event_dict["sender"] + if "state_key" in event_dict: + self.state_key = event_dict["state_key"] - auth_events = DictProperty("auth_events") - depth = DictProperty("depth") - content = DictProperty("content") - hashes = DictProperty("hashes") - origin = DictProperty("origin") - origin_server_ts = DictProperty("origin_server_ts") - prev_events = DictProperty("prev_events") - redacts = DefaultDictProperty("redacts", None) - room_id = DictProperty("room_id") - sender = DictProperty("sender") - state_key = DictProperty("state_key") - type = DictProperty("type") - user_id = DictProperty("sender") + self.internal_metadata = _EventInternalMetadata(internal_metadata_dict) @property def event_id(self) -> str: diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index a9364670a1..d4684755bc 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -1108,7 +1108,7 @@ class EventCreationHandler: # it's not a self-redaction (to avoid having to look up whether the # user is actually admin or not). is_admin_redaction = False - if event.type == EventTypes.Redaction: + if event.type == EventTypes.Redaction and event.redacts: original_event = await self.store.get_event( event.redacts, redact_behaviour=EventRedactBehaviour.AS_IS, @@ -1195,7 +1195,7 @@ class EventCreationHandler: # TODO: Make sure the signatures actually are correct. event.signatures.update(returned_invite.signatures) - if event.type == EventTypes.Redaction: + if event.type == EventTypes.Redaction and event.redacts: original_event = await self.store.get_event( event.redacts, redact_behaviour=EventRedactBehaviour.AS_IS, |