Rename DispatchCtx to Dispatch (#43563)
This commit is contained in:
+14
-14
@@ -27,7 +27,7 @@ func GetUserByID(c *models.ReqContext) response.Response {
|
||||
func getUserUserProfile(ctx context.Context, userID int64) response.Response {
|
||||
query := models.GetUserProfileQuery{UserId: userID}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, &query); err != nil {
|
||||
if err := bus.Dispatch(ctx, &query); err != nil {
|
||||
if errors.Is(err, models.ErrUserNotFound) {
|
||||
return response.Error(404, models.ErrUserNotFound.Error(), nil)
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func getUserUserProfile(ctx context.Context, userID int64) response.Response {
|
||||
|
||||
getAuthQuery := models.GetAuthInfoQuery{UserId: userID}
|
||||
query.Result.AuthLabels = []string{}
|
||||
if err := bus.DispatchCtx(ctx, &getAuthQuery); err == nil {
|
||||
if err := bus.Dispatch(ctx, &getAuthQuery); err == nil {
|
||||
authLabel := GetAuthProviderLabel(getAuthQuery.Result.AuthModule)
|
||||
query.Result.AuthLabels = append(query.Result.AuthLabels, authLabel)
|
||||
query.Result.IsExternal = true
|
||||
@@ -50,7 +50,7 @@ func getUserUserProfile(ctx context.Context, userID int64) response.Response {
|
||||
// GET /api/users/lookup
|
||||
func GetUserByLoginOrEmail(c *models.ReqContext) response.Response {
|
||||
query := models.GetUserByLoginQuery{LoginOrEmail: c.Query("loginOrEmail")}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
if errors.Is(err, models.ErrUserNotFound) {
|
||||
return response.Error(404, models.ErrUserNotFound.Error(), nil)
|
||||
}
|
||||
@@ -110,7 +110,7 @@ func UpdateUserActiveOrg(c *models.ReqContext) response.Response {
|
||||
|
||||
cmd := models.SetUsingOrgCommand{UserId: userID, OrgId: orgID}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
return response.Error(500, "Failed to change active organization", err)
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ func handleUpdateUser(ctx context.Context, cmd models.UpdateUserCommand) respons
|
||||
}
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, &cmd); err != nil {
|
||||
if err := bus.Dispatch(ctx, &cmd); err != nil {
|
||||
return response.Error(500, "Failed to update user", err)
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func GetUserTeams(c *models.ReqContext) response.Response {
|
||||
func getUserTeamList(ctx context.Context, orgID int64, userID int64) response.Response {
|
||||
query := models.GetTeamsByUserQuery{OrgId: orgID, UserId: userID}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, &query); err != nil {
|
||||
if err := bus.Dispatch(ctx, &query); err != nil {
|
||||
return response.Error(500, "Failed to get user teams", err)
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ func GetUserOrgList(c *models.ReqContext) response.Response {
|
||||
func getUserOrgList(ctx context.Context, userID int64) response.Response {
|
||||
query := models.GetUserOrgListQuery{UserId: userID}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, &query); err != nil {
|
||||
if err := bus.Dispatch(ctx, &query); err != nil {
|
||||
return response.Error(500, "Failed to get user organizations", err)
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ func getUserOrgList(ctx context.Context, userID int64) response.Response {
|
||||
func validateUsingOrg(ctx context.Context, userID int64, orgID int64) bool {
|
||||
query := models.GetUserOrgListQuery{UserId: userID}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, &query); err != nil {
|
||||
if err := bus.Dispatch(ctx, &query); err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ func UserSetUsingOrg(c *models.ReqContext) response.Response {
|
||||
|
||||
cmd := models.SetUsingOrgCommand{UserId: c.UserId, OrgId: orgID}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
return response.Error(500, "Failed to change active organization", err)
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ func (hs *HTTPServer) ChangeActiveOrgAndRedirectToHome(c *models.ReqContext) {
|
||||
|
||||
cmd := models.SetUsingOrgCommand{UserId: c.UserId, OrgId: orgID}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
hs.NotFoundHandler(c)
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ func ChangeUserPassword(c *models.ReqContext) response.Response {
|
||||
|
||||
userQuery := models.GetUserByIdQuery{Id: c.UserId}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &userQuery); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &userQuery); err != nil {
|
||||
return response.Error(500, "Could not read user from database", err)
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ func ChangeUserPassword(c *models.ReqContext) response.Response {
|
||||
return response.Error(500, "Failed to encode password", err)
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
return response.Error(500, "Failed to change user password", err)
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ func SetHelpFlag(c *models.ReqContext) response.Response {
|
||||
HelpFlags1: *bitmask,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
return response.Error(500, "Failed to update help flag", err)
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ func ClearHelpFlags(c *models.ReqContext) response.Response {
|
||||
HelpFlags1: models.HelpFlags1(0),
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
return response.Error(500, "Failed to update help flag", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user