summary refs log tree commit diff
path: root/synapse/events/__init__.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2020-10-13 22:02:41 +0100
committerRichard van der Hoff <richard@matrix.org>2020-10-13 23:24:50 +0100
commit898196f1cca419c0d2b60529c86ddff3cea83072 (patch)
tree83685785d64861d6d227e0e5b6db6ef1e20f0332 /synapse/events/__init__.py
parentAllow ThirdPartyRules modules to replace event content (diff)
downloadsynapse-898196f1cca419c0d2b60529c86ddff3cea83072.tar.xz
guard against accidental modification
Diffstat (limited to 'synapse/events/__init__.py')
-rw-r--r--synapse/events/__init__.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py
index 7a51d0a22f..65df62107f 100644
--- a/synapse/events/__init__.py
+++ b/synapse/events/__init__.py
@@ -312,6 +312,12 @@ class EventBase(metaclass=abc.ABCMeta):
         """
         return [e for e, _ in self.auth_events]
 
+    def freeze(self):
+        """'Freeze' the event dict, so it cannot be modified by accident"""
+
+        # this will be a no-op if the event dict is already frozen.
+        self._dict = freeze(self._dict)
+
 
 class FrozenEvent(EventBase):
     format_version = EventFormatVersions.V1  # All events of this type are V1