mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Some maintenance
This commit is contained in:
parent
783012a066
commit
ba0ebb115d
|
|
@ -3,6 +3,7 @@ package routing
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"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 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{
|
logrus.WithError(err).WithFields(logrus.Fields{
|
||||||
"userID": device.UserID,
|
"userID": device.UserID,
|
||||||
"serverName": serverName,
|
"serverName": serverName,
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ type Admin struct {
|
||||||
Leaver *Leaver
|
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(
|
func (r *Admin) PerformAdminEvacuateRoom(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
roomID string,
|
roomID string,
|
||||||
|
|
@ -139,6 +139,7 @@ func (r *Admin) PerformAdminEvacuateRoom(
|
||||||
return affected, err
|
return affected, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PerformAdminEvacuateUser will remove the given user from all rooms.
|
||||||
func (r *Admin) PerformAdminEvacuateUser(
|
func (r *Admin) PerformAdminEvacuateUser(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
userID string,
|
userID string,
|
||||||
|
|
@ -184,6 +185,7 @@ func (r *Admin) PerformAdminEvacuateUser(
|
||||||
return affected, nil
|
return affected, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PerformAdminPurgeRoom removes all traces for the given room from the database.
|
||||||
func (r *Admin) PerformAdminPurgeRoom(
|
func (r *Admin) PerformAdminPurgeRoom(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
roomID string,
|
roomID string,
|
||||||
|
|
@ -193,6 +195,12 @@ func (r *Admin) PerformAdminPurgeRoom(
|
||||||
return err
|
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")
|
logrus.WithField("room_id", roomID).Warn("Purging room from roomserver")
|
||||||
if err := r.DB.PurgeRoom(ctx, roomID); err != nil {
|
if err := r.DB.PurgeRoom(ctx, roomID); err != nil {
|
||||||
logrus.WithField("room_id", roomID).WithError(err).Warn("Failed to purge room from roomserver")
|
logrus.WithField("room_id", roomID).WithError(err).Warn("Failed to purge room from roomserver")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue