summaryrefslogtreecommitdiff
path: root/synapse/storage/data_stores/main/registration.py
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/storage/data_stores/main/registration.py')
-rw-r--r--synapse/storage/data_stores/main/registration.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/synapse/storage/data_stores/main/registration.py b/synapse/storage/data_stores/main/registration.py
index 6c5b2928..89147ad5 100644
--- a/synapse/storage/data_stores/main/registration.py
+++ b/synapse/storage/data_stores/main/registration.py
@@ -459,7 +459,7 @@ class RegistrationWorkerStore(SQLBaseStore):
WHERE appservice_id IS NULL
"""
)
- count, = txn.fetchone()
+ (count,) = txn.fetchone()
return count
ret = yield self.runInteraction("count_users", _count_users)
@@ -488,14 +488,14 @@ class RegistrationWorkerStore(SQLBaseStore):
we can. Unfortunately, it's possible some of them are already taken by
existing users, and there may be gaps in the already taken range. This
function returns the start of the first allocatable gap. This is to
- avoid the case of ID 10000000 being pre-allocated, so us wasting the
- first (and shortest) many generated user IDs.
+ avoid the case of ID 1000 being pre-allocated and starting at 1001 while
+ 0-999 are available.
"""
def _find_next_generated_user_id(txn):
- # We bound between '@1' and '@a' to avoid pulling the entire table
+ # We bound between '@0' and '@a' to avoid pulling the entire table
# out.
- txn.execute("SELECT name FROM users WHERE '@1' <= name AND name < '@a'")
+ txn.execute("SELECT name FROM users WHERE '@0' <= name AND name < '@a'")
regex = re.compile(r"^@(\d+):")
@@ -577,6 +577,19 @@ class RegistrationWorkerStore(SQLBaseStore):
return self._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):
+ """Delete all threepid this user has bound
+
+ Args:
+ user_id: The user id to delete all threepids of
+
+ """
+ return self._simple_delete(
+ "user_threepids",
+ keyvalues={"user_id": user_id},
desc="user_delete_threepids",
)