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

Show erasure status when listing users in the Admin API #14205

Merged
merged 15 commits into from
Oct 21, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Explicitly convert erased to bool to make SQLite consistent with Po…
…stgres

This also adds us an easy way in to fix the other accidentally integered columns.
tadzik committed Oct 20, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 795f779b7b3cf4ceb6099fce1d5c7b913ab2f102
7 changes: 7 additions & 0 deletions synapse/storage/databases/main/__init__.py
Original file line number Diff line number Diff line change
@@ -279,6 +279,13 @@ def get_users_paginate_txn(
args += [limit, start]
txn.execute(sql, args)
users = self.db_pool.cursor_to_dict(txn)

# some of those boolean values are returned as integers when we're on SQLite
columns_to_boolify = ['erased']
for user in users:
for column in columns_to_boolify:
user[column] = bool(user[column])

return users, count

return await self.db_pool.runInteraction(
7 changes: 3 additions & 4 deletions tests/rest/admin/test_user.py
Original file line number Diff line number Diff line change
@@ -1230,10 +1230,9 @@ def test_deactivate_user_erase_true(self) -> None:
access_token=self.admin_user_tok,
)

self.assertEqual(
1,
len(list(filter(lambda user: user["erased"], channel.json_body["users"]))),
)
users = {user["name"]: user for user in channel.json_body["users"]}

self.assertIs(users["@user:test"]["erased"], True)

@override_config({"max_avatar_size": 1234})
def test_deactivate_user_erase_true_avatar_nonnull_but_empty(self) -> None: