Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
Don't push if an user account has expired
Browse files Browse the repository at this point in the history
  • Loading branch information
MatMaul committed Aug 28, 2020
1 parent f87bf7e commit d05a48a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/58.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't push if an user account has expired.
20 changes: 20 additions & 0 deletions synapse/push/pusherpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]]

Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit d05a48a

Please sign in to comment.