Convert simple_delete to async/await. (#8191)

This commit is contained in:
Patrick Cloke 2020-08-27 14:16:41 -04:00 committed by GitHub
parent 9b7ac03af3
commit b71d4a094c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 90 additions and 37 deletions

View file

@ -529,21 +529,21 @@ class RegistrationWorkerStore(SQLBaseStore):
"user_get_threepids",
)
def user_delete_threepid(self, user_id, medium, address):
return self.db_pool.simple_delete(
async def user_delete_threepid(self, user_id, medium, address) -> None:
await self.db_pool.simple_delete(
"user_threepids",
keyvalues={"user_id": user_id, "medium": medium, "address": address},
desc="user_delete_threepid",
)
def user_delete_threepids(self, user_id: str):
async def user_delete_threepids(self, user_id: str) -> None:
"""Delete all threepid this user has bound
Args:
user_id: The user id to delete all threepids of
"""
return self.db_pool.simple_delete(
await self.db_pool.simple_delete(
"user_threepids",
keyvalues={"user_id": user_id},
desc="user_delete_threepids",
@ -597,21 +597,20 @@ class RegistrationWorkerStore(SQLBaseStore):
desc="user_get_bound_threepids",
)
def remove_user_bound_threepid(self, user_id, medium, address, id_server):
async def remove_user_bound_threepid(
self, user_id: str, medium: str, address: str, id_server: str
) -> None:
"""The server proxied an unbind request to the given identity server on
behalf of the given user, so we remove the mapping of threepid to
identity server.
Args:
user_id (str)
medium (str)
address (str)
id_server (str)
Returns:
Deferred
user_id
medium
address
id_server
"""
return self.db_pool.simple_delete(
await self.db_pool.simple_delete(
table="user_threepid_id_server",
keyvalues={
"user_id": user_id,
@ -1247,14 +1246,14 @@ class RegistrationStore(RegistrationBackgroundUpdateStore):
desc="add_user_pending_deactivation",
)
def del_user_pending_deactivation(self, user_id):
async def del_user_pending_deactivation(self, user_id: str) -> None:
"""
Removes the given user to the table of users who need to be parted from all the
rooms they're in, effectively marking that user as fully deactivated.
"""
# XXX: This should be simple_delete_one but we failed to put a unique index on
# the table, so somehow duplicate entries have ended up in it.
return self.db_pool.simple_delete(
await self.db_pool.simple_delete(
"users_pending_deactivation",
keyvalues={"user_id": user_id},
desc="del_user_pending_deactivation",