Make select more sensible when dseleting access tokens, rename pusher deletion to match access token deletion and make exception arg optional.
This commit is contained in:
parent
f523177850
commit
af59826a2f
|
@ -441,7 +441,7 @@ class AuthHandler(BaseHandler):
|
|||
yield self.store.user_delete_access_tokens(
|
||||
user_id, except_access_token_ids
|
||||
)
|
||||
yield self.hs.get_pusherpool().remove_pushers_by_user_except_access_tokens(
|
||||
yield self.hs.get_pusherpool().remove_pushers_by_user(
|
||||
user_id, except_access_token_ids
|
||||
)
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ class PusherPool:
|
|||
yield self.remove_pusher(p['app_id'], p['pushkey'], p['user_name'])
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def remove_pushers_by_user_except_access_tokens(self, user_id, except_token_ids):
|
||||
def remove_pushers_by_user(self, user_id, except_token_ids=[]):
|
||||
all = yield self.store.get_all_pushers()
|
||||
logger.info(
|
||||
"Removing all pushers for user %s except access tokens ids %r",
|
||||
|
|
|
@ -198,14 +198,12 @@ class RegistrationStore(SQLBaseStore):
|
|||
def user_delete_access_tokens(self, user_id, except_token_ids):
|
||||
def f(txn):
|
||||
txn.execute(
|
||||
"SELECT id, token FROM access_tokens WHERE user_id = ? LIMIT 50",
|
||||
(user_id,)
|
||||
"SELECT id, token FROM access_tokens "
|
||||
"WHERE user_id = ? AND id not in LIMIT 50",
|
||||
(user_id,except_token_ids)
|
||||
)
|
||||
rows = txn.fetchall()
|
||||
for r in rows:
|
||||
if r[0] in except_token_ids:
|
||||
continue
|
||||
|
||||
txn.call_after(self.get_user_by_access_token.invalidate, (r[1],))
|
||||
txn.execute(
|
||||
"DELETE FROM access_tokens WHERE id in (%s)" % ",".join(
|
||||
|
|
Loading…
Reference in New Issue