summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2020-10-14 12:00:52 +0100
committerGitHub <noreply@github.com>2020-10-14 12:00:52 +0100
commit3ee97a2748f64a772878b6e4d4775aed2e0534a2 (patch)
tree3fe7153c9d0a9f3795dfe0de93854e6ee61310e8 /synapse
parentAdd correct M_BAD_JSON error code to /profile/{userId}/displayname (#8517) (diff)
downloadsynapse-3ee97a2748f64a772878b6e4d4775aed2e0534a2.tar.xz
Make sure a retention policy is a state event (#8527)
* Make sure a retention policy is a state event

* Changelog
Diffstat (limited to 'synapse')
-rw-r--r--synapse/events/validator.py3
-rw-r--r--synapse/storage/databases/main/events.py4
2 files changed, 7 insertions, 0 deletions
diff --git a/synapse/events/validator.py b/synapse/events/validator.py
index 9df35b54ba..5f9af8529b 100644
--- a/synapse/events/validator.py
+++ b/synapse/events/validator.py
@@ -83,6 +83,9 @@ class EventValidator:
         Args:
             event (FrozenEvent): The event to validate.
         """
+        if not event.is_state():
+            raise SynapseError(code=400, msg="must be a state event")
+
         min_lifetime = event.content.get("min_lifetime")
         max_lifetime = event.content.get("max_lifetime")
 
diff --git a/synapse/storage/databases/main/events.py b/synapse/storage/databases/main/events.py
index fdb17745f6..ba3b1769b0 100644
--- a/synapse/storage/databases/main/events.py
+++ b/synapse/storage/databases/main/events.py
@@ -1270,6 +1270,10 @@ class PersistEventsStore:
             )
 
     def _store_retention_policy_for_room_txn(self, txn, event):
+        if not event.is_state():
+            logger.debug("Ignoring non-state m.room.retention event")
+            return
+
         if hasattr(event, "content") and (
             "min_lifetime" in event.content or "max_lifetime" in event.content
         ):