Some maintenance

This commit is contained in:
Till Faelligen 2023-04-24 11:19:01 +02:00
parent 783012a066
commit ba0ebb115d
No known key found for this signature in database
GPG key ID: ACCDC9606D472758
2 changed files with 16 additions and 1 deletions

View file

@ -3,6 +3,7 @@ package routing
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"
@ -231,6 +232,12 @@ func AdminDownloadState(req *http.Request, device *api.Device, rsAPI roomserverA
}
}
if err = rsAPI.PerformAdminDownloadState(req.Context(), roomID, device.UserID, spec.ServerName(serverName)); err != nil {
if errors.Is(err, eventutil.ErrRoomNoExists) {
return util.JSONResponse{
Code: 200,
JSON: jsonerror.NotFound(eventutil.ErrRoomNoExists.Error()),
}
}
logrus.WithError(err).WithFields(logrus.Fields{
"userID": device.UserID,
"serverName": serverName,

View file

@ -40,7 +40,7 @@ type Admin struct {
Leaver *Leaver
}
// PerformEvacuateRoom will remove all local users from the given room.
// PerformAdminEvacuateRoom will remove all local users from the given room.
func (r *Admin) PerformAdminEvacuateRoom(
ctx context.Context,
roomID string,
@ -139,6 +139,7 @@ func (r *Admin) PerformAdminEvacuateRoom(
return affected, err
}
// PerformAdminEvacuateUser will remove the given user from all rooms.
func (r *Admin) PerformAdminEvacuateUser(
ctx context.Context,
userID string,
@ -184,6 +185,7 @@ func (r *Admin) PerformAdminEvacuateUser(
return affected, nil
}
// PerformAdminPurgeRoom removes all traces for the given room from the database.
func (r *Admin) PerformAdminPurgeRoom(
ctx context.Context,
roomID string,
@ -193,6 +195,12 @@ func (r *Admin) PerformAdminPurgeRoom(
return err
}
// Evacuate the room before purging it from the database
if _, err := r.PerformAdminEvacuateRoom(ctx, roomID); err != nil {
logrus.WithField("room_id", roomID).WithError(err).Warn("Failed to evacuate room before purging")
return err
}
logrus.WithField("room_id", roomID).Warn("Purging room from roomserver")
if err := r.DB.PurgeRoom(ctx, roomID); err != nil {
logrus.WithField("room_id", roomID).WithError(err).Warn("Failed to purge room from roomserver")