-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add an option to disable purge in delete room admin API #7964
Changes from 2 commits
1e555b3
133a210
0354646
390d035
926de16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add an option to purge room or not with delete room admin endpoint (`POST /_synapse/admin/v1/rooms/<room_id>/delete`). Contributed by @dklimpel. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -283,6 +283,23 @@ def test_block_is_not_bool(self): | |
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"]) | ||
self.assertEqual(Codes.BAD_JSON, channel.json_body["errcode"]) | ||
|
||
def test_purge_is_not_bool(self): | ||
""" | ||
If parameter `purge` is not boolean, return an error | ||
""" | ||
body = json.dumps({"purge": "NotBool"}) | ||
|
||
request, channel = self.make_request( | ||
"POST", | ||
self.url, | ||
content=body.encode(encoding="utf_8"), | ||
access_token=self.admin_user_tok, | ||
) | ||
self.render(request) | ||
|
||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"]) | ||
self.assertEqual(Codes.BAD_JSON, channel.json_body["errcode"]) | ||
|
||
def test_purge_room_and_block(self): | ||
"""Test to purge a room and block it. | ||
Members will not be moved to a new room and will not receive a message. | ||
|
@@ -297,7 +314,7 @@ def test_purge_room_and_block(self): | |
# Assert one user in room | ||
self._is_member(room_id=self.room_id, user_id=self.other_user) | ||
|
||
body = json.dumps({"block": True}) | ||
body = json.dumps({"block": True, "purge": True}) | ||
|
||
request, channel = self.make_request( | ||
"POST", | ||
|
@@ -331,7 +348,7 @@ def test_purge_room_and_not_block(self): | |
# Assert one user in room | ||
self._is_member(room_id=self.room_id, user_id=self.other_user) | ||
|
||
body = json.dumps({"block": False}) | ||
body = json.dumps({"block": False, "purge": True}) | ||
|
||
request, channel = self.make_request( | ||
"POST", | ||
|
@@ -351,6 +368,41 @@ def test_purge_room_and_not_block(self): | |
self._is_blocked(self.room_id, expect=False) | ||
self._has_no_members(self.room_id) | ||
|
||
def test_block_room_and_not_purge(self): | ||
"""Test to block a room and do not purge it. | ||
dklimpel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Members will not be moved to a new room and will not receive a message. | ||
dklimpel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
# Test that room is not purged | ||
with self.assertRaises(AssertionError): | ||
self._is_purged(self.room_id) | ||
|
||
# Test that room is not blocked | ||
self._is_blocked(self.room_id, expect=False) | ||
|
||
# Assert one user in room | ||
self._is_member(room_id=self.room_id, user_id=self.other_user) | ||
|
||
body = json.dumps({"block": False, "purge": False}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a typo? Should this have been There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. I think so. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
To check my understanding, I think no block and no purge would
I agree that this isn't a useful mode of operation! Sounds like it ought to caught and rejected with 400 bad request There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you have to check everything. Maybe it's a edge case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My concern is that someone might accidentally use the API in this way, and not realise that the room can come back to haunt them. (Is there a use case for shutting down the room with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea for an use case |
||
|
||
request, channel = self.make_request( | ||
"POST", | ||
self.url.encode("ascii"), | ||
content=body.encode(encoding="utf_8"), | ||
access_token=self.admin_user_tok, | ||
) | ||
self.render(request) | ||
|
||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"]) | ||
self.assertEqual(None, channel.json_body["new_room_id"]) | ||
self.assertEqual(self.other_user, channel.json_body["kicked_users"][0]) | ||
self.assertIn("failed_to_kick_users", channel.json_body) | ||
self.assertIn("local_aliases", channel.json_body) | ||
|
||
with self.assertRaises(AssertionError): | ||
self._is_purged(self.room_id) | ||
self._is_blocked(self.room_id, expect=False) | ||
self._has_no_members(self.room_id) | ||
|
||
def test_shutdown_room_consent(self): | ||
"""Test that we can shutdown rooms with local users who have not | ||
yet accepted the privacy policy. This used to fail when we tried to | ||
|
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.
I would probably rewrite this sentence as something like: