forked from MirrorHub/synapse
Make sure a retention policy is a state event (#8527)
* Make sure a retention policy is a state event * Changelog
This commit is contained in:
parent
ec606ea9e3
commit
3ee97a2748
3 changed files with 8 additions and 0 deletions
1
changelog.d/8527.bugfix
Normal file
1
changelog.d/8527.bugfix
Normal file
|
@ -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.
|
|
@ -83,6 +83,9 @@ class EventValidator:
|
||||||
Args:
|
Args:
|
||||||
event (FrozenEvent): The event to validate.
|
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")
|
min_lifetime = event.content.get("min_lifetime")
|
||||||
max_lifetime = event.content.get("max_lifetime")
|
max_lifetime = event.content.get("max_lifetime")
|
||||||
|
|
||||||
|
|
|
@ -1270,6 +1270,10 @@ class PersistEventsStore:
|
||||||
)
|
)
|
||||||
|
|
||||||
def _store_retention_policy_for_room_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 (
|
if hasattr(event, "content") and (
|
||||||
"min_lifetime" in event.content or "max_lifetime" in event.content
|
"min_lifetime" in event.content or "max_lifetime" in event.content
|
||||||
):
|
):
|
||||||
|
|
Loading…
Reference in a new issue