1 files changed, 5 insertions, 3 deletions
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py
index 9f910eac9c..0b3c656e90 100644
--- a/synapse/storage/registration.py
+++ b/synapse/storage/registration.py
@@ -642,7 +642,9 @@ class RegistrationStore(
FROM users
LEFT JOIN access_tokens ON (access_tokens.user_id = users.name)
LEFT JOIN user_threepids ON (user_threepids.user_id = users.name)
- WHERE password_hash IS NULL OR password_hash = ''
+ WHERE (users.password_hash IS NULL OR users.password_hash = '')
+ AND (users.appservice_id IS NULL OR users.appservice_id = '')
+ AND users.is_guest = 0
AND users.name > ?
GROUP BY users.name
ORDER BY users.name ASC
@@ -660,13 +662,13 @@ class RegistrationStore(
for user in rows:
if not user["count_tokens"] and not user["count_threepids"]:
- self.set_user_deactivated_status_txn(txn, user["user_id"], True)
+ self.set_user_deactivated_status_txn(txn, user["name"], True)
rows_processed_nb += 1
logger.info("Marked %d rows as deactivated", rows_processed_nb)
self._background_update_progress_txn(
- txn, "users_set_deactivated_flag", {"user_id": rows[-1]["user_id"]}
+ txn, "users_set_deactivated_flag", {"user_id": rows[-1]["name"]}
)
if batch_size > len(rows):
|