Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 8998217

Browse files
authored
Fixed a bug with reactivating users with the admin API (#8362)
Fixes: #8359 Trying to reactivate a user with the admin API (`PUT /_synapse/admin/v2/users/<user_name>`) causes an internal server error. Seems to be a regression in #8033.
1 parent 4da01f9 commit 8998217

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

changelog.d/8362.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed a regression in v1.19.0 with reactivating users through the admin API.

synapse/storage/databases/main/user_erasure_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def f(txn):
100100
return
101101

102102
# They are there, delete them.
103-
self.simple_delete_one_txn(
103+
self.db_pool.simple_delete_one_txn(
104104
txn, "erased_users", keyvalues={"user_id": user_id}
105105
)
106106

tests/rest/admin/test_user.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,10 @@ def test_reactivate_user(self):
874874
)
875875
self.render(request)
876876
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
877+
self._is_erased("@user:test", False)
878+
d = self.store.mark_user_erased("@user:test")
879+
self.assertIsNone(self.get_success(d))
880+
self._is_erased("@user:test", True)
877881

878882
# Attempt to reactivate the user (without a password).
879883
request, channel = self.make_request(
@@ -906,6 +910,7 @@ def test_reactivate_user(self):
906910
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
907911
self.assertEqual("@user:test", channel.json_body["name"])
908912
self.assertEqual(False, channel.json_body["deactivated"])
913+
self._is_erased("@user:test", False)
909914

910915
def test_set_user_as_admin(self):
911916
"""
@@ -996,6 +1001,15 @@ def test_accidental_deactivation_prevention(self):
9961001
# Ensure they're still alive
9971002
self.assertEqual(0, channel.json_body["deactivated"])
9981003

1004+
def _is_erased(self, user_id, expect):
1005+
"""Assert that the user is erased or not
1006+
"""
1007+
d = self.store.is_user_erased(user_id)
1008+
if expect:
1009+
self.assertTrue(self.get_success(d))
1010+
else:
1011+
self.assertFalse(self.get_success(d))
1012+
9991013

10001014
class UserMembershipRestTestCase(unittest.HomeserverTestCase):
10011015

0 commit comments

Comments
 (0)