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:
|