(req *http.Request, device *userapi.Device, rsAPI roomserverAPI.ClientRoomserverAPI)
| 12 | ) |
| 13 | |
| 14 | func AdminEvacuateRoom(req *http.Request, device *userapi.Device, rsAPI roomserverAPI.ClientRoomserverAPI) util.JSONResponse { |
| 15 | if device.AccountType != userapi.AccountTypeAdmin { |
| 16 | return util.JSONResponse{ |
| 17 | Code: http.StatusForbidden, |
| 18 | JSON: jsonerror.Forbidden("This API can only be used by admin users."), |
| 19 | } |
| 20 | } |
| 21 | vars, err := httputil.URLDecodeMapValues(mux.Vars(req)) |
| 22 | if err != nil { |
| 23 | return util.ErrorResponse(err) |
| 24 | } |
| 25 | roomID, ok := vars["roomID"] |
| 26 | if !ok { |
| 27 | return util.JSONResponse{ |
| 28 | Code: http.StatusBadRequest, |
| 29 | JSON: jsonerror.MissingArgument("Expecting room ID."), |
| 30 | } |
| 31 | } |
| 32 | res := &roomserverAPI.PerformAdminEvacuateRoomResponse{} |
| 33 | rsAPI.PerformAdminEvacuateRoom( |
| 34 | req.Context(), |
| 35 | &roomserverAPI.PerformAdminEvacuateRoomRequest{ |
| 36 | RoomID: roomID, |
| 37 | }, |
| 38 | res, |
| 39 | ) |
| 40 | if err := res.Error; err != nil { |
| 41 | return err.JSONResponse() |
| 42 | } |
| 43 | return util.JSONResponse{ |
| 44 | Code: 200, |
| 45 | JSON: map[string]interface{}{ |
| 46 | "affected": res.Affected, |
| 47 | }, |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | func AdminEvacuateUser(req *http.Request, device *userapi.Device, rsAPI roomserverAPI.ClientRoomserverAPI) util.JSONResponse { |
| 52 | if device.AccountType != userapi.AccountTypeAdmin { |
no test coverage detected