diff options
author | Richard van der Hoff <github@rvanderhoff.org.uk> | 2017-11-29 17:56:46 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-29 17:56:46 +0000 |
commit | 7a48a6b63e9b4c1a81e04f2a0c8ac31a053ff29a (patch) | |
tree | f8d8f53bdf064d0033be76bc3c4ce8bc1582540f /synapse/push | |
parent | Merge pull request #2718 from matrix-org/rav/notify_logcontexts (diff) | |
parent | Delete devices in various logout situations (diff) | |
download | synapse-7a48a6b63e9b4c1a81e04f2a0c8ac31a053ff29a.tar.xz |
Merge pull request #2722 from matrix-org/rav/delete_device_on_logout
Delete devices and pushers on logouts etc
Diffstat (limited to 'synapse/push')
-rw-r--r-- | synapse/push/pusherpool.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/synapse/push/pusherpool.py b/synapse/push/pusherpool.py index 34cb108dcb..134e89b371 100644 --- a/synapse/push/pusherpool.py +++ b/synapse/push/pusherpool.py @@ -103,19 +103,25 @@ class PusherPool: yield self.remove_pusher(p['app_id'], p['pushkey'], p['user_name']) @defer.inlineCallbacks - def remove_pushers_by_user(self, user_id, except_access_token_id=None): - all = yield self.store.get_all_pushers() - logger.info( - "Removing all pushers for user %s except access tokens id %r", - user_id, except_access_token_id - ) - for p in all: - if p['user_name'] == user_id and p['access_token'] != except_access_token_id: + def remove_pushers_by_access_token(self, user_id, access_tokens): + """Remove the pushers for a given user corresponding to a set of + access_tokens. + + Args: + user_id (str): user to remove pushers for + access_tokens (Iterable[int]): access token *ids* to remove pushers + for + """ + tokens = set(access_tokens) + for p in (yield self.store.get_pushers_by_user_id(user_id)): + if p['access_token'] in tokens: logger.info( "Removing pusher for app id %s, pushkey %s, user %s", p['app_id'], p['pushkey'], p['user_name'] ) - yield self.remove_pusher(p['app_id'], p['pushkey'], p['user_name']) + yield self.remove_pusher( + p['app_id'], p['pushkey'], p['user_name'], + ) @defer.inlineCallbacks def on_new_notifications(self, min_stream_id, max_stream_id): |