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.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/clientapi/routing/admin.go b/clientapi/routing/admin.go
index 125b3847..523b88c9 100644
--- a/clientapi/routing/admin.go
+++ b/clientapi/routing/admin.go
@@ -47,3 +47,40 @@ func AdminEvacuateRoom(req *http.Request, device *userapi.Device, rsAPI roomserv
},
}
}
+
+func AdminEvacuateUser(req *http.Request, device *userapi.Device, rsAPI roomserverAPI.ClientRoomserverAPI) util.JSONResponse {
+ if device.AccountType != userapi.AccountTypeAdmin {
+ return util.JSONResponse{
+ Code: http.StatusForbidden,
+ JSON: jsonerror.Forbidden("This API can only be used by admin users."),
+ }
+ }
+ vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
+ if err != nil {
+ return util.ErrorResponse(err)
+ }
+ userID, ok := vars["userID"]
+ if !ok {
+ return util.JSONResponse{
+ Code: http.StatusBadRequest,
+ JSON: jsonerror.MissingArgument("Expecting user ID."),
+ }
+ }
+ res := &roomserverAPI.PerformAdminEvacuateUserResponse{}
+ rsAPI.PerformAdminEvacuateUser(
+ req.Context(),
+ &roomserverAPI.PerformAdminEvacuateUserRequest{
+ UserID: userID,
+ },
+ res,
+ )
+ if err := res.Error; err != nil {
+ return err.JSONResponse()
+ }
+ return util.JSONResponse{
+ Code: 200,
+ JSON: map[string]interface{}{
+ "affected": res.Affected,
+ },
+ }
+}