diff --git a/changelog.d/58.misc b/changelog.d/58.misc new file mode 100644 index 0000000000..64098a68a4 --- /dev/null +++ b/changelog.d/58.misc @@ -0,0 +1 @@ +Don't push if an user account has expired. diff --git a/synapse/push/pusherpool.py b/synapse/push/pusherpool.py index 2456f12f46..35022540ea 100644 --- a/synapse/push/pusherpool.py +++ b/synapse/push/pusherpool.py @@ -66,6 +66,8 @@ def __init__(self, hs: "HomeServer"): self._pusher_shard_config = hs.config.push.pusher_shard_config self._instance_name = hs.get_instance_name() + self._account_validity = hs.config.account_validity + # map from user id to app_id:pushkey to pusher self.pushers = {} # type: Dict[str, Dict[str, Union[HttpPusher, EmailPusher]]] @@ -196,6 +198,15 @@ def on_new_notifications(self, min_stream_id, max_stream_id): for u in users_affected: if u in self.pushers: + # Don't push if the user account has expired + if self._account_validity.enabled: + expiration_ts = yield self.store.get_expiration_ts_for_user(u) + if ( + expiration_ts is not None + and self.clock.time_msec() >= expiration_ts + ): + continue + for p in self.pushers[u].values(): p.on_new_notifications(min_stream_id, max_stream_id) @@ -217,6 +228,15 @@ def on_new_receipts(self, min_stream_id, max_stream_id, affected_room_ids): for u in users_affected: if u in self.pushers: + # Don't push if the user account has expired + if self._account_validity.enabled: + expiration_ts = yield self.store.get_expiration_ts_for_user(u) + if ( + expiration_ts is not None + and self.clock.time_msec() >= expiration_ts + ): + continue + for p in self.pushers[u].values(): p.on_new_receipts(min_stream_id, max_stream_id)