Evacuate room before purging

This commit is contained in:
Till Faelligen 2023-02-06 10:16:06 +01:00
parent 753971dc9b
commit b2f177689b
No known key found for this signature in database
GPG key ID: ACCDC9606D472758
2 changed files with 15 additions and 2 deletions

View file

@ -68,7 +68,7 @@ This endpoint instructs Dendrite to immediately query `/devices/{userID}` on a f
## POST `/_dendrite/admin/purgeRoom/{roomID}`
This endpoint instructs Dendrite to remove the given room from its database. It does **NOT** remove media files. Depending on the size of the room, this may take a while. Will return an empty JSON once other components were instructed to delete the room.
This endpoint instructs Dendrite to remove the given room from its database. Before doing so, it will evacuate all local users from the room. It does **NOT** remove media files. Depending on the size of the room, this may take a while. Will return an empty JSON once other components were instructed to delete the room.
## POST `/_synapse/admin/v1/send_server_notice`

View file

@ -257,7 +257,20 @@ func (r *Admin) PerformAdminPurgeRoom(
return nil
}
logrus.WithField("room_id", req.RoomID).Warn("Purging room from roomserver")
evacResp := &api.PerformAdminEvacuateRoomResponse{}
if err := r.PerformAdminEvacuateRoom(ctx, &api.PerformAdminEvacuateRoomRequest{RoomID: req.RoomID}, evacResp); err != nil {
res.Error = &api.PerformError{
Code: api.PerformErrorBadRequest,
Msg: fmt.Sprintf("failed to evacuate room: %s", err),
}
return nil
}
logrus.WithFields(logrus.Fields{
"room_id": req.RoomID,
"evacuated_users": len(evacResp.Affected),
}).Warn("Evacuated room, purging room from roomserver now")
if err := r.DB.PurgeRoom(ctx, req.RoomID); err != nil {
logrus.WithField("room_id", req.RoomID).WithError(err).Warn("Failed to purge room from roomserver")
res.Error = &api.PerformError{