diff --git a/synapse/visibility.py b/synapse/visibility.py index 452a2d50fb..bfde05fe81 100644 --- a/synapse/visibility.py +++ b/synapse/visibility.py @@ -237,6 +237,15 @@ async def filter_and_transform_events_for_client( # to the cache! cloned = clone_event(filtered) cloned.unsigned[EventUnsignedContentFields.MEMBERSHIP] = user_membership + if storage.main.config.experimental.msc4354_enabled: + sticky_duration = cloned.sticky_duration() + if sticky_duration: + now = storage.main.clock.time_msec() + expires_at = min(cloned.origin_server_ts, now) + sticky_duration + if expires_at > now: + cloned.unsigned[EventUnsignedContentFields.STICKY_TTL] = ( + expires_at - now + ) return cloned