aboutsummaryrefslogtreecommitdiff
path: root/clientapi/routing/routing.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-04-29 09:10:08 +0100
committerNeil Alexander <neilalexander@users.noreply.github.com>2022-04-29 09:10:08 +0100
commit2a4517f8e6c7f68d8bd94f0b4640b142f2d3ac52 (patch)
tree41f2dcd544c7043ee2a6425bb3a000e9c1b91c64 /clientapi/routing/routing.go
parent0d4b8eadaa45ff65cddd4b882a156de33c4bed7e (diff)
Move admin functions into their own file in the client API
Diffstat (limited to 'clientapi/routing/routing.go')
-rw-r--r--clientapi/routing/routing.go35
1 files changed, 1 insertions, 34 deletions
diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go
index ec90b80d..ba1c76b8 100644
--- a/clientapi/routing/routing.go
+++ b/clientapi/routing/routing.go
@@ -122,40 +122,7 @@ func Setup(
dendriteAdminRouter.Handle("/admin/evacuateRoom/{roomID}",
httputil.MakeAuthAPI("admin_evacuate_room", userAPI, func(req *http.Request, device *userapi.Device) 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)
- }
- roomID, ok := vars["roomID"]
- if !ok {
- return util.JSONResponse{
- Code: http.StatusBadRequest,
- JSON: jsonerror.MissingArgument("Expecting room ID."),
- }
- }
- res := &roomserverAPI.PerformAdminEvacuateRoomResponse{}
- rsAPI.PerformAdminEvacuateRoom(
- req.Context(),
- &roomserverAPI.PerformAdminEvacuateRoomRequest{
- RoomID: roomID,
- },
- res,
- )
- if err := res.Error; err != nil {
- return err.JSONResponse()
- }
- return util.JSONResponse{
- Code: 200,
- JSON: map[string]interface{}{
- "affected": res.Affected,
- },
- }
+ return AdminEvacuateRoom(req, device, rsAPI)
}),
).Methods(http.MethodGet, http.MethodOptions)