mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
synapseadmin: add support for synchronous room delete
This commit is contained in:
parent
49d2f39183
commit
50f0b5fa7d
1 changed files with 29 additions and 0 deletions
|
|
@ -127,6 +127,14 @@ type RespDeleteRoom struct {
|
|||
DeleteID string `json:"delete_id"`
|
||||
}
|
||||
|
||||
type RespDeleteRoomStatus struct {
|
||||
Status string `json:"status,omitempty"`
|
||||
KickedUsers []id.UserID `json:"kicked_users,omitempty"`
|
||||
FailedToKickUsers []id.UserID `json:"failed_to_kick_users,omitempty"`
|
||||
LocalAliases []id.RoomAlias `json:"local_aliases,omitempty"`
|
||||
NewRoomID id.RoomID `json:"new_room_id,omitempty"`
|
||||
}
|
||||
|
||||
// DeleteRoom deletes a room from the server, optionally blocking it and/or purging all data from the database.
|
||||
//
|
||||
// This calls the async version of the endpoint, which will return immediately and delete the room in the background.
|
||||
|
|
@ -139,6 +147,27 @@ func (cli *Client) DeleteRoom(ctx context.Context, roomID id.RoomID, req ReqDele
|
|||
return resp, err
|
||||
}
|
||||
|
||||
// DeleteRoomSync deletes a room from the server, optionally blocking it and/or purging all data from the database.
|
||||
//
|
||||
// This calls the synchronous version of the endpoint, which will block until the room is deleted.
|
||||
//
|
||||
// https://element-hq.github.io/synapse/latest/admin_api/rooms.html#version-1-old-version
|
||||
func (cli *Client) DeleteRoomSync(ctx context.Context, roomID id.RoomID, req ReqDeleteRoom) (resp RespDeleteRoomStatus, err error) {
|
||||
reqURL := cli.BuildAdminURL("v1", "rooms", roomID)
|
||||
httpClient := &http.Client{}
|
||||
_, err = cli.Client.MakeFullRequest(ctx, mautrix.FullRequest{
|
||||
Method: http.MethodDelete,
|
||||
URL: reqURL,
|
||||
RequestJSON: &req,
|
||||
ResponseJSON: &resp,
|
||||
MaxAttempts: 1,
|
||||
// Use a fresh HTTP client without timeouts
|
||||
Client: httpClient,
|
||||
})
|
||||
httpClient.CloseIdleConnections()
|
||||
return
|
||||
}
|
||||
|
||||
type RespRoomsMembers struct {
|
||||
Members []id.UserID `json:"members"`
|
||||
Total int `json:"total"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue