From ad3d66f23a03061c0579fdd5379351df2e174fbd Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Thu, 18 Dec 2025 14:15:27 +0000 Subject: [PATCH] Fix MSC divergence: duration should be clamped, not ignored if high --- synapse/events/__init__.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py index b88535cf9a..d723fa0847 100644 --- a/synapse/events/__init__.py +++ b/synapse/events/__init__.py @@ -329,12 +329,8 @@ class EventBase(metaclass=abc.ABCMeta): return None sticky_duration_ms = sticky_obj.get("duration_ms", None) # MSC: Valid values are the integer range 0-MAX_DURATION_MS - if ( - type(sticky_duration_ms) is int - and sticky_duration_ms >= 0 - and sticky_duration_ms <= StickyEvent.MAX_DURATION_MS - ): - return sticky_duration_ms + if type(sticky_duration_ms) is int and sticky_duration_ms >= 0: + return min(sticky_duration_ms, StickyEvent.MAX_DURATION_MS) return None def __str__(self) -> str: