diff options
author | Brendan Abolivier <babolivier@matrix.org> | 2019-07-24 14:21:01 +0200 |
---|---|---|
committer | Brendan Abolivier <babolivier@matrix.org> | 2019-08-28 18:16:17 +0100 |
commit | 70714595bcc2394d62f9413d8dbcede8296eecd4 (patch) | |
tree | 401f87e3e260454e06e9761bbb8c5aa20ac91d71 /synapse/visibility.py | |
parent | Merge pull request #5702 from matrix-org/babolivier/3pid-invite (diff) | |
download | synapse-70714595bcc2394d62f9413d8dbcede8296eecd4.tar.xz |
Implement per-room message retention policies
Diffstat (limited to 'synapse/visibility.py')
-rw-r--r-- | synapse/visibility.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/synapse/visibility.py b/synapse/visibility.py index 16c40cd74c..5b6562b481 100644 --- a/synapse/visibility.py +++ b/synapse/visibility.py @@ -92,6 +92,12 @@ def filter_events_for_client(store, user_id, events, is_peeking=False, erased_senders = yield store.are_users_erased((e.sender for e in events)) + room_ids = set(e.room_id for e in events) + retention_policies = {} + + for room_id in room_ids: + retention_policies[room_id] = yield store.get_retention_policy_for_room(room_id) + def allowed(event): """ Args: @@ -109,6 +115,15 @@ def filter_events_for_client(store, user_id, events, is_peeking=False, if not event.is_state() and event.sender in ignore_list: return None + retention_policy = retention_policies[event.room_id] + max_lifetime = retention_policy.get("max_lifetime") + + if max_lifetime is not None: + oldest_allowed_ts = store.clock.time_msec() - max_lifetime + + if event.origin_server_ts < oldest_allowed_ts: + return None + if event.event_id in always_include_ids: return event |