-
Notifications
You must be signed in to change notification settings - Fork 305
Add admin API for fetching room reports #18253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
@turt2live the trial unit tests are failing FWIW |
I'm not seeing errors which look related to this PR. Is there somewhere else I should be looking? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor things, but on the whole looks good! Tests are failing due to this PR though, see below.
"""Report a room""" | ||
channel = self.make_request( | ||
"POST", | ||
"rooms/%s/report" % room_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit test failure logs can be seen here.
The shorthand form doesn't actually work here, as it prepends /_matrix/client/r0/
:
Lines 412 to 420 in 10812bc
# Decorate it to be the full path, if we're using shorthand | |
if ( | |
shorthand | |
and not path.startswith(b"/_matrix") | |
and not path.startswith(b"/_synapse") | |
): | |
if path.startswith(b"/"): | |
path = path[1:] | |
path = b"/_matrix/client/r0/" + path |
whereas /rooms/{roomId}/report
only listens on v3
:
synapse/synapse/rest/client/reporting.py
Lines 105 to 119 in 10812bc
class ReportRoomRestServlet(RestServlet): | |
"""This endpoint lets clients report a room for abuse. | |
Introduced by MSC4151: https://github.com/matrix-org/matrix-spec-proposals/pull/4151 | |
""" | |
# Cast the Iterable to a list so that we can `append` below. | |
PATTERNS = list( | |
client_patterns( | |
"/rooms/(?P<room_id>[^/]*)/report$", | |
releases=("v3",), | |
unstable=False, | |
v1=False, | |
) | |
) |
I'd recommend putting the full path to avoid the shorthand logic:
"rooms/%s/report" % room_id, | |
f"/_matrix/client/v3/rooms/{room_id}/report", |
"""Report a room, but omit reason""" | ||
channel = self.make_request( | ||
"POST", | ||
"rooms/%s/report" % room_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"rooms/%s/report" % room_id, | |
f"/_matrix/client/v3/rooms/{room_id}/report", |
``` | ||
|
||
To paginate, check for `next_token` and if present, call the endpoint again with `from` | ||
set to the value of `next_token`. This will return a new page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set to the value of `next_token`. This will return a new page. | |
set to the value of `next_token` and the same `limit`. This will return a new page. |
If the endpoint does not return a `next_token` then there are no more reports to | ||
paginate through. | ||
|
||
**URL parameters:** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**URL parameters:** | |
**Query parameters:** |
# Originally licensed under the Apache License, Version 2.0: | ||
# <http://www.apache.org/licenses/LICENSE-2.0>. | ||
# | ||
# [This file includes modifications made by New Vector Limited] | ||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is a new file, this section isn't needed.
# Originally licensed under the Apache License, Version 2.0: | |
# <http://www.apache.org/licenses/LICENSE-2.0>. | |
# | |
# [This file includes modifications made by New Vector Limited] | |
# |
self.assertIn("user_id", c) | ||
self.assertIn("canonical_alias", c) | ||
self.assertIn("name", c) | ||
self.assertIn("reason", c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make sure we don't accidentally introduce another field (since we're taking raw output from a database storage function:
self.assertIn("reason", c) | |
self.assertIn("reason", c) | |
self.assertEqual(len(c.keys()), 7) |
# | ||
# Originally licensed under the Apache License, Version 2.0: | ||
# <http://www.apache.org/licenses/LICENSE-2.0>. | ||
# | ||
# [This file includes modifications made by New Vector Limited] | ||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# | |
# Originally licensed under the Apache License, Version 2.0: | |
# <http://www.apache.org/licenses/LICENSE-2.0>. | |
# | |
# [This file includes modifications made by New Vector Limited] | |
# |
Very much a copy/paste of the event reporting API: https://element-hq.github.io/synapse/latest/admin_api/event_reports.html
Differences:
sender
or sender filtering - rooms don't have senders.score
- there isn't any.event_id
- there isn't any.Pull Request Checklist
EventStore
toEventWorkerStore
.".code blocks
.(run the linters)