summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2020-01-31 13:20:16 +0000
committerErik Johnston <erik@matrix.org>2020-01-31 13:20:16 +0000
commit91e895cb4e29e3ed0a1dbd5d9705abba66bf3852 (patch)
tree578f1d4575e92ba01b8abf78b6e7555eb101d152
parentNewsfile (diff)
downloadsynapse-91e895cb4e29e3ed0a1dbd5d9705abba66bf3852.tar.xz
Fix FrozenEventBase
-rw-r--r--synapse/events/__init__.py24
1 files changed, 7 insertions, 17 deletions
diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py
index 2691ac5545..26a8f7b97e 100644
--- a/synapse/events/__init__.py
+++ b/synapse/events/__init__.py
@@ -189,6 +189,8 @@ class EventBase(object):
     redacts = _event_dict_property("redacts", None)
     room_id = _event_dict_property("room_id")
     sender = _event_dict_property("sender")
+    state_key = _event_dict_property("state_key")
+    type = _event_dict_property("type")
     user_id = _event_dict_property("sender")
 
     @property
@@ -265,16 +267,6 @@ class FrozenEventBase(EventBase):
     def event_id(self) -> str:
         raise NotImplementedError()
 
-    @property
-    def type(self) -> str:
-        raise NotImplementedError()
-
-    @property
-    def state_key(self) -> str:
-        """Raises if there is no state key.
-        """
-        raise NotImplementedError()
-
 
 class FrozenEvent(FrozenEventBase):
     format_version = EventFormatVersions.V1  # All events of this type are V1
@@ -300,10 +292,7 @@ class FrozenEvent(FrozenEventBase):
         else:
             frozen_dict = event_dict
 
-        self.event_id = event_dict["event_id"]
-        self.type = event_dict["type"]
-        if "state_key" in event_dict:
-            self.state_key = event_dict["state_key"]
+        self._event_id = event_dict["event_id"]
 
         super(FrozenEvent, self).__init__(
             frozen_dict,
@@ -313,6 +302,10 @@ class FrozenEvent(FrozenEventBase):
             rejected_reason=rejected_reason,
         )
 
+    @property
+    def event_id(self) -> str:
+        return self._event_id
+
     def __str__(self):
         return self.__repr__()
 
@@ -351,9 +344,6 @@ class FrozenEventV2(FrozenEventBase):
             frozen_dict = event_dict
 
         self._event_id = None
-        self.type = event_dict["type"]
-        if "state_key" in event_dict:
-            self.state_key = event_dict["state_key"]
 
         super(FrozenEventV2, self).__init__(
             frozen_dict,