Skip to content

Commit

Permalink
- __parse_parameter_deactivated renamed to _parse_parameter_deactivated
Browse files Browse the repository at this point in the history
- 16874.feature: link fixed.
  • Loading branch information
afechler committed Feb 23, 2024
1 parent 5c305a0 commit 53a777a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion changelog.d/16874.feature
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Handling of the query parameter `deactivated` in [List Accounts (V3)](https://element-hq.github.io/synapse/v1.99/admin_api/user_admin_api.html#list-accounts) [admin API](https://element-hq.github.io/synapse/v1.99/usage/administration/admin_api/index.html) adjusted, to filter deactivated users in user queries.
Handling of the query parameter `deactivated` in [List Accounts](https://element-hq.github.io/synapse/v1.99/admin_api/user_admin_api.html#list-accounts) [admin API](https://element-hq.github.io/synapse/v1.99/usage/administration/admin_api/index.html) adjusted, to filter deactivated users in user queries.
5 changes: 3 additions & 2 deletions docs/admin_api/user_admin_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ Body parameters:
not be changed. If `null` is given, the user type will be cleared.
Other allowed options are: `bot` and `support`.

## List Accounts (V2)
## List Accounts
### List Accounts (V2)

This API returns all local user accounts.
By default, the response is ordered by ascending user ID.
Expand Down Expand Up @@ -287,7 +288,7 @@ The following fields are returned in the JSON response body:

*Added in Synapse 1.93:* the `locked` query parameter and response field.

## List Accounts (V3)
### List Accounts (V3)

This API returns all local user accounts (see v2). In contrast to v2, the query parameter `deactivated` is handled differently.

Expand Down
6 changes: 3 additions & 3 deletions synapse/rest/admin/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
errcode=Codes.INVALID_PARAM,
)

deactivated = self.__parse_parameter_deactivated(request)
deactivated = self._parse_parameter_deactivated(request)

locked = parse_boolean(request, "locked", default=False)
admins = parse_boolean(request, "admins")
Expand Down Expand Up @@ -183,14 +183,14 @@ def _filter(a: attr.Attribute) -> bool:

return HTTPStatus.OK, ret

def __parse_parameter_deactivated(self, request: SynapseRequest) -> bool | None:
def _parse_parameter_deactivated(self, request: SynapseRequest) -> bool | None:
return None if parse_boolean(request, "deactivated") else False


class UsersRestServletV3(UsersRestServletV2):
PATTERNS = admin_patterns("/users$", "v3")

def __parse_parameter_deactivated(self, request: SynapseRequest) -> bool | None:
def _parse_parameter_deactivated(self, request: SynapseRequest) -> bool | None:
return parse_boolean(request, "deactivated")


Expand Down
6 changes: 3 additions & 3 deletions tests/rest/admin/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def test_all_users(self) -> None:

channel = self.make_request(
"GET",
self.url + "?deactivated=true",
f"{self.url}?deactivated=true",
{},
access_token=self.admin_user_tok,
)
Expand Down Expand Up @@ -1180,7 +1180,7 @@ def test_erasure_status(self) -> None:
# They should appear in the list users API, marked as not erased.
channel = self.make_request(
"GET",
self.url,
f"{self.url}?deactivated=true",
access_token=self.admin_user_tok,
)
users = {user["name"]: user for user in channel.json_body["users"]}
Expand Down Expand Up @@ -1244,7 +1244,7 @@ def _order_test(
dir: The direction of ordering to give the server
"""

url = self.url + "?"
url = f"{self.url}?deactivated=true&"
if order_by is not None:
url += "order_by=%s&" % (order_by,)
if dir is not None and dir in ("b", "f"):
Expand Down

0 comments on commit 53a777a

Please sign in to comment.