Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Make sure a retention policy is a state event (#8527)
Browse files Browse the repository at this point in the history
* Make sure a retention policy is a state event

* Changelog
  • Loading branch information
babolivier authored Oct 14, 2020
1 parent ec606ea commit 3ee97a2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/8527.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug introduced in v1.7.0 that could cause Synapse to insert values from non-state `m.room.retention` events into the `room_retention` database table.
3 changes: 3 additions & 0 deletions synapse/events/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def _validate_retention(self, event):
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")

Expand Down
4 changes: 4 additions & 0 deletions synapse/storage/databases/main/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,10 @@ def _store_room_message_txn(self, txn, event):
)

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
):
Expand Down

0 comments on commit 3ee97a2

Please sign in to comment.