mirror of
https://github.com/element-hq/synapse.git
synced 2025-04-08 21:53:59 +00:00
Add removal of score parameter
This commit is contained in:
parent
e446686690
commit
be9aa688f7
3 changed files with 13 additions and 15 deletions
|
@ -563,6 +563,6 @@ class ExperimentalConfig(Config):
|
|||
|
||||
# MSC4277: Harmonizing the reporting endpoints
|
||||
#
|
||||
# If enabled, respond with HTTP 200 on reporting requests regardless
|
||||
# of the subject's existence.
|
||||
# If enabled, ignore the score parameter and respond with HTTP 200 on
|
||||
# reporting requests regardless of the subject's existence.
|
||||
self.msc4277_enabled: bool = experimental.get("msc4277_enabled", False)
|
||||
|
|
|
@ -69,7 +69,10 @@ class ReportEventRestServlet(RestServlet):
|
|||
"Param 'reason' must be a string",
|
||||
Codes.BAD_JSON,
|
||||
)
|
||||
if type(body.get("score", 0)) is not int: # noqa: E721
|
||||
if (
|
||||
not self.hs.config.experimental.msc4277_enabled
|
||||
and type(body.get("score", 0)) is not int
|
||||
): # noqa: E721
|
||||
raise SynapseError(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
"Param 'score' must be an integer",
|
||||
|
|
|
@ -81,6 +81,11 @@ class ReportEventTestCase(unittest.HomeserverTestCase):
|
|||
data = {"reason": None, "score": None}
|
||||
self._assert_status(400, data)
|
||||
|
||||
@override_config({"experimental_features": {"msc4277_enabled": True}})
|
||||
def test_score_str(self) -> None:
|
||||
data = {"score": "string"}
|
||||
self._assert_status(200, data)
|
||||
|
||||
def test_cannot_report_nonexistent_event(self) -> None:
|
||||
"""
|
||||
Tests that we don't accept event reports for events which do not exist.
|
||||
|
@ -98,12 +103,7 @@ class ReportEventTestCase(unittest.HomeserverTestCase):
|
|||
msg=channel.result["body"],
|
||||
)
|
||||
|
||||
@override_config(
|
||||
{
|
||||
"experimental_features": {"msc4277_enabled": True},
|
||||
"forget_rooms_on_leave": True,
|
||||
}
|
||||
)
|
||||
@override_config({"experimental_features": {"msc4277_enabled": True}})
|
||||
def test_event_existence_hidden(self) -> None:
|
||||
"""
|
||||
Tests that the requester cannot infer the existence of an event.
|
||||
|
@ -211,12 +211,7 @@ class ReportRoomTestCase(unittest.HomeserverTestCase):
|
|||
msg=channel.result["body"],
|
||||
)
|
||||
|
||||
@override_config(
|
||||
{
|
||||
"experimental_features": {"msc4277_enabled": True},
|
||||
"forget_rooms_on_leave": True,
|
||||
}
|
||||
)
|
||||
@override_config({"experimental_features": {"msc4277_enabled": True}})
|
||||
def test_room_existence_hidden(self) -> None:
|
||||
"""
|
||||
Tests that the requester cannot infer the existence of a room.
|
||||
|
|
Loading…
Add table
Reference in a new issue