(req *http.Request, device *userapi.Device, rsAPI roomserverAPI.ClientRoomserverAPI)
| 49 | } |
| 50 | |
| 51 | func AdminEvacuateUser(req *http.Request, device *userapi.Device, rsAPI roomserverAPI.ClientRoomserverAPI) util.JSONResponse { |
| 52 | if device.AccountType != userapi.AccountTypeAdmin { |
| 53 | return util.JSONResponse{ |
| 54 | Code: http.StatusForbidden, |
| 55 | JSON: jsonerror.Forbidden("This API can only be used by admin users."), |
| 56 | } |
| 57 | } |
| 58 | vars, err := httputil.URLDecodeMapValues(mux.Vars(req)) |
| 59 | if err != nil { |
| 60 | return util.ErrorResponse(err) |
| 61 | } |
| 62 | userID, ok := vars["userID"] |
| 63 | if !ok { |
| 64 | return util.JSONResponse{ |
| 65 | Code: http.StatusBadRequest, |
| 66 | JSON: jsonerror.MissingArgument("Expecting user ID."), |
| 67 | } |
| 68 | } |
| 69 | res := &roomserverAPI.PerformAdminEvacuateUserResponse{} |
| 70 | rsAPI.PerformAdminEvacuateUser( |
| 71 | req.Context(), |
| 72 | &roomserverAPI.PerformAdminEvacuateUserRequest{ |
| 73 | UserID: userID, |
| 74 | }, |
| 75 | res, |
| 76 | ) |
| 77 | if err := res.Error; err != nil { |
| 78 | return err.JSONResponse() |
| 79 | } |
| 80 | return util.JSONResponse{ |
| 81 | Code: 200, |
| 82 | JSON: map[string]interface{}{ |
| 83 | "affected": res.Affected, |
| 84 | }, |
| 85 | } |
| 86 | } |
no test coverage detected