diff options
author | Dirk Klimpel <5740567+dklimpel@users.noreply.github.com> | 2021-12-08 17:59:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-08 16:59:40 +0000 |
commit | 7ecaa3b976b04dc5b2c6786aa18845016b80dd01 (patch) | |
tree | b66e9caab3e56bbca80b2526322e92b616a292c0 /synapse/rest/admin/statistics.py | |
parent | Document the usage of refresh tokens. (#11427) (diff) | |
download | synapse-7ecaa3b976b04dc5b2c6786aa18845016b80dd01.tar.xz |
Clean up `synapse.rest.admin` (#11535)
Diffstat (limited to 'synapse/rest/admin/statistics.py')
-rw-r--r-- | synapse/rest/admin/statistics.py | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/synapse/rest/admin/statistics.py b/synapse/rest/admin/statistics.py index ca41fd45f2..7a6546372e 100644 --- a/synapse/rest/admin/statistics.py +++ b/synapse/rest/admin/statistics.py @@ -37,7 +37,6 @@ class UserMediaStatisticsRestServlet(RestServlet): PATTERNS = admin_patterns("/statistics/users/media$") def __init__(self, hs: "HomeServer"): - self.hs = hs self.auth = hs.get_auth() self.store = hs.get_datastore() @@ -45,19 +44,16 @@ class UserMediaStatisticsRestServlet(RestServlet): await assert_requester_is_admin(self.auth, request) order_by = parse_string( - request, "order_by", default=UserSortOrder.USER_ID.value + request, + "order_by", + default=UserSortOrder.USER_ID.value, + allowed_values=( + UserSortOrder.MEDIA_LENGTH.value, + UserSortOrder.MEDIA_COUNT.value, + UserSortOrder.USER_ID.value, + UserSortOrder.DISPLAYNAME.value, + ), ) - if order_by not in ( - UserSortOrder.MEDIA_LENGTH.value, - UserSortOrder.MEDIA_COUNT.value, - UserSortOrder.USER_ID.value, - UserSortOrder.DISPLAYNAME.value, - ): - raise SynapseError( - HTTPStatus.BAD_REQUEST, - "Unknown value for order_by: %s" % (order_by,), - errcode=Codes.INVALID_PARAM, - ) start = parse_integer(request, "from", default=0) if start < 0: |