Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add delete room admin endpoint #7613

Merged
merged 15 commits into from
Jul 14, 2020

Conversation

dklimpel
Copy link
Contributor

@dklimpel dklimpel commented Jun 1, 2020

The Delete Room admin API allows server admins to remove rooms from server
and block these rooms.
DELETE /_synapse/admin/v1/rooms/<room_id>
It is a combination and improvement of "Shutdown room" and "Purge room" API.

Fixes: #6425

It also fix a bug in synapse/storage/data_stores/main/room.py in get_room_with_stats.
It should return None if the room is unknown. But it returns an IndexError.

def get_room_with_stats(self, room_id: str):
"""Retrieve room with statistics.
Args:
room_id: The ID of the room to retrieve.
Returns:
A dict containing the room information, or None if the room is unknown.

Related to:

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
  • Pull request includes a sign off
  • Code style is correct (run the linters)

Signed-off-by: Dirk Klimpel dirk@klimpel.org

@dklimpel dklimpel marked this pull request as ready for review June 1, 2020 15:39
@erikjohnston erikjohnston requested a review from a team June 4, 2020 13:01
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than cutting-and-pasting the implementation of ShutdownRoom, please could you factor out the code to a handler so that it can be shared?

By the way, please could you join #synapse-dev:matrix.org so that we can collaborate more easily on some of this stuff? It's not very high-volume.

docs/admin_api/rooms.md Outdated Show resolved Hide resolved
docs/admin_api/rooms.md Outdated Show resolved Hide resolved
@richvdh richvdh added the X-Awaiting-Changes A contributed PR which needs changes and re-review before it can be merged label Jun 5, 2020
@dklimpel
Copy link
Contributor Author

dklimpel commented Jun 5, 2020

rather than cutting-and-pasting the implementation of ShutdownRoom, please could you factor out the code to a handler so that it can be shared?

By the way, please could you join #synapse-dev:matrix.org so that we can collaborate more easily on some of this stuff? It's not very high-volume.

I have moved it to an own handler.
The room handler has not tests at the moment.

@erikjohnston erikjohnston removed the X-Awaiting-Changes A contributed PR which needs changes and re-review before it can be merged label Jun 11, 2020
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bunch of stylistic things here. Thanks!

docs/admin_api/rooms.md Show resolved Hide resolved
docs/admin_api/rooms.md Outdated Show resolved Hide resolved
docs/admin_api/rooms.md Outdated Show resolved Hide resolved
docs/admin_api/rooms.md Show resolved Hide resolved
synapse/storage/data_stores/main/room.py Show resolved Hide resolved
docs/admin_api/rooms.md Outdated Show resolved Hide resolved
docs/admin_api/rooms.md Outdated Show resolved Hide resolved
synapse/rest/admin/rooms.py Outdated Show resolved Hide resolved
docs/admin_api/rooms.md Outdated Show resolved Hide resolved
docs/admin_api/rooms.md Outdated Show resolved Hide resolved
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
@richvdh richvdh self-requested a review June 12, 2020 08:41
@dklimpel
Copy link
Contributor Author

@richvdh: ready for review

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nearly there!

synapse/handlers/room.py Outdated Show resolved Hide resolved
synapse/handlers/room.py Outdated Show resolved Hide resolved
synapse/rest/admin/rooms.py Outdated Show resolved Hide resolved
synapse/handlers/room.py Outdated Show resolved Hide resolved
synapse/handlers/room.py Outdated Show resolved Hide resolved
@richvdh richvdh added the X-Awaiting-Changes A contributed PR which needs changes and re-review before it can be merged label Jul 2, 2020
@dklimpel dklimpel requested a review from richvdh July 12, 2020 10:24
@ell1e
Copy link

ell1e commented Jul 12, 2020

Just a feedback from reading this pull request as an outsider:

It is a combination and improvement of "Shutdown room" and "Purge room" API.

The "improvement" that also made it into the documentation description of this new function seems quite confusing to me. To me it looks like essentially this new "delete" just does shutdown followed by purge, is that not all it does? If the "improvement" just means the code is cleaned up as well then I suggest it should be removed from the code comment / documentation description since it seems irrelevant and misleading at best in there, it sounds like it does more than just shutdown & purge but the details are secret for some reason. Otherwise I suggest that it is clarified what exactly this "improvement" means in terms of actual behavior.

@richvdh richvdh removed the X-Awaiting-Changes A contributed PR which needs changes and re-review before it can be merged label Jul 14, 2020
docs/admin_api/rooms.md Outdated Show resolved Hide resolved
@richvdh
Copy link
Member

richvdh commented Jul 14, 2020

@ell1e : I don't disagree: that line isn't terribly clear. That said, I don't want to hold this PR up on another round of documentation tweaking.

For the record, the new API is slightly more flexible than using the two existing APIs separately (for example: Shutdown room automatically moves all existing users to a new room. That is optional with the new APIs.) There is, of course, also a good argument that these improvements should be ported back to the shutdown room api...

(Aside: when you comment on a PR, please can you comment on a line in the "files changed" tab. That (a) helps people see which bit of the PR you're talking about, and (b) means that the conversation is threaded rather than being mixed in with all the other traffic on the PR.)

@richvdh
Copy link
Member

richvdh commented Jul 14, 2020

Ah bother. @dklimpel I don't have sign-off from you. Please can you add a signed-off-by comment here as per https://github.com/matrix-org/synapse/blob/develop/CONTRIBUTING.md#sign-off?

@richvdh richvdh added the X-Awaiting-Changes A contributed PR which needs changes and re-review before it can be merged label Jul 14, 2020
@dklimpel
Copy link
Contributor Author

Ah bother. @dklimpel I don't have sign-off from you. Please can you add a signed-off-by comment here as per https://github.com/matrix-org/synapse/blob/develop/CONTRIBUTING.md#sign-off?

@richvdh I have added it #7613 (comment)

@richvdh richvdh removed the X-Awaiting-Changes A contributed PR which needs changes and re-review before it can be merged label Jul 14, 2020
@richvdh richvdh merged commit 491f0da into matrix-org:develop Jul 14, 2020
@dklimpel dklimpel deleted the admin_api_delete_room branch July 16, 2020 08:19
richvdh pushed a commit that referenced this pull request Jul 27, 2020
Converts tests/rest/admin/test_room.py to have unix file endings after they were accidentally changed in #7613.

Keeping the same changelog as #7613 as it hasn't gone out in a release yet.
babolivier pushed a commit that referenced this pull request Sep 1, 2021
* commit '491f0dab1':
  Add delete room admin endpoint (#7613)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delete a room (Admin API)
4 participants