aboutsummaryrefslogtreecommitdiff
path: root/clientapi/routing/admin.go
diff options
context:
space:
mode:
Diffstat (limited to 'clientapi/routing/admin.go')
-rw-r--r--clientapi/routing/admin.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/clientapi/routing/admin.go b/clientapi/routing/admin.go
index dbd91337..4b4dedfd 100644
--- a/clientapi/routing/admin.go
+++ b/clientapi/routing/admin.go
@@ -1,6 +1,7 @@
package routing
import (
+ "context"
"encoding/json"
"fmt"
"net/http"
@@ -98,6 +99,37 @@ func AdminEvacuateUser(req *http.Request, cfg *config.ClientAPI, device *userapi
}
}
+func AdminPurgeRoom(req *http.Request, cfg *config.ClientAPI, device *userapi.Device, rsAPI roomserverAPI.ClientRoomserverAPI) util.JSONResponse {
+ vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
+ if err != nil {
+ return util.ErrorResponse(err)
+ }
+ roomID, ok := vars["roomID"]
+ if !ok {
+ return util.JSONResponse{
+ Code: http.StatusBadRequest,
+ JSON: jsonerror.MissingArgument("Expecting room ID."),
+ }
+ }
+ res := &roomserverAPI.PerformAdminPurgeRoomResponse{}
+ if err := rsAPI.PerformAdminPurgeRoom(
+ context.Background(),
+ &roomserverAPI.PerformAdminPurgeRoomRequest{
+ RoomID: roomID,
+ },
+ res,
+ ); err != nil {
+ return util.ErrorResponse(err)
+ }
+ if err := res.Error; err != nil {
+ return err.JSONResponse()
+ }
+ return util.JSONResponse{
+ Code: 200,
+ JSON: res,
+ }
+}
+
func AdminResetPassword(req *http.Request, cfg *config.ClientAPI, device *userapi.Device, userAPI userapi.ClientUserAPI) util.JSONResponse {
if req.Body == nil {
return util.JSONResponse{