Rename DispatchCtx to Dispatch (#43563)
This commit is contained in:
+1
-1
@@ -22,7 +22,7 @@ func (hs *HTTPServer) AdminGetSettings(c *models.ReqContext) response.Response {
|
||||
func AdminGetStats(c *models.ReqContext) response.Response {
|
||||
statsQuery := models.GetAdminStatsQuery{}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &statsQuery); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &statsQuery); err != nil {
|
||||
return response.Error(500, "Failed to get admin stats from database", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ func AdminUpdateUserPassword(c *models.ReqContext) response.Response {
|
||||
|
||||
userQuery := models.GetUserByIdQuery{Id: 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)
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func AdminUpdateUserPassword(c *models.ReqContext) response.Response {
|
||||
NewPassword: passwordHashed,
|
||||
}
|
||||
|
||||
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 user password", err)
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ func AdminDeleteUser(c *models.ReqContext) response.Response {
|
||||
|
||||
cmd := models.DeleteUserCommand{UserId: userID}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrUserNotFound) {
|
||||
return response.Error(404, models.ErrUserNotFound.Error(), nil)
|
||||
}
|
||||
@@ -137,12 +137,12 @@ func (hs *HTTPServer) AdminDisableUser(c *models.ReqContext) response.Response {
|
||||
|
||||
// External users shouldn't be disabled from API
|
||||
authInfoQuery := &models.GetAuthInfoQuery{UserId: userID}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), authInfoQuery); !errors.Is(err, models.ErrUserNotFound) {
|
||||
if err := bus.Dispatch(c.Req.Context(), authInfoQuery); !errors.Is(err, models.ErrUserNotFound) {
|
||||
return response.Error(500, "Could not disable external user", nil)
|
||||
}
|
||||
|
||||
disableCmd := models.DisableUserCommand{UserId: userID, IsDisabled: true}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &disableCmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &disableCmd); err != nil {
|
||||
if errors.Is(err, models.ErrUserNotFound) {
|
||||
return response.Error(404, models.ErrUserNotFound.Error(), nil)
|
||||
}
|
||||
@@ -163,12 +163,12 @@ func AdminEnableUser(c *models.ReqContext) response.Response {
|
||||
|
||||
// External users shouldn't be disabled from API
|
||||
authInfoQuery := &models.GetAuthInfoQuery{UserId: userID}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), authInfoQuery); !errors.Is(err, models.ErrUserNotFound) {
|
||||
if err := bus.Dispatch(c.Req.Context(), authInfoQuery); !errors.Is(err, models.ErrUserNotFound) {
|
||||
return response.Error(500, "Could not enable external user", nil)
|
||||
}
|
||||
|
||||
disableCmd := models.DisableUserCommand{UserId: userID, IsDisabled: false}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &disableCmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &disableCmd); err != nil {
|
||||
if errors.Is(err, models.ErrUserNotFound) {
|
||||
return response.Error(404, models.ErrUserNotFound.Error(), nil)
|
||||
}
|
||||
|
||||
+21
-21
@@ -24,7 +24,7 @@ func ValidateOrgAlert(c *models.ReqContext) {
|
||||
id := c.ParamsInt64(":alertId")
|
||||
query := models.GetAlertByIdQuery{Id: id}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
c.JsonApiErr(404, "Alert not found", nil)
|
||||
return
|
||||
}
|
||||
@@ -47,7 +47,7 @@ func GetAlertStatesForDashboard(c *models.ReqContext) response.Response {
|
||||
DashboardId: c.QueryInt64("dashboardId"),
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to fetch alert states", err)
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ func GetAlerts(c *models.ReqContext) response.Response {
|
||||
Permission: models.PERMISSION_VIEW,
|
||||
}
|
||||
|
||||
err := bus.DispatchCtx(c.Req.Context(), &searchQuery)
|
||||
err := bus.Dispatch(c.Req.Context(), &searchQuery)
|
||||
if err != nil {
|
||||
return response.Error(500, "List alerts failed", err)
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func GetAlerts(c *models.ReqContext) response.Response {
|
||||
query.State = states
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "List alerts failed", err)
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ func GetAlert(c *models.ReqContext) response.Response {
|
||||
id := c.ParamsInt64(":alertId")
|
||||
query := models.GetAlertByIdQuery{Id: id}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "List alerts failed", err)
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ func GetAlertNotifications(c *models.ReqContext) response.Response {
|
||||
func getAlertNotificationsInternal(c *models.ReqContext) ([]*models.AlertNotification, error) {
|
||||
query := &models.GetAllAlertNotificationsQuery{OrgId: c.OrgId}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), query); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ func GetAlertNotificationByID(c *models.ReqContext) response.Response {
|
||||
return response.Error(404, "Alert notification not found", nil)
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), query); err != nil {
|
||||
return response.Error(500, "Failed to get alert notifications", err)
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ func GetAlertNotificationByUID(c *models.ReqContext) response.Response {
|
||||
return response.Error(404, "Alert notification not found", nil)
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), query); err != nil {
|
||||
return response.Error(500, "Failed to get alert notifications", err)
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ func CreateAlertNotification(c *models.ReqContext) response.Response {
|
||||
}
|
||||
cmd.OrgId = c.OrgId
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrAlertNotificationWithSameNameExists) || errors.Is(err, models.ErrAlertNotificationWithSameUIDExists) {
|
||||
return response.Error(409, "Failed to create alert notification", err)
|
||||
}
|
||||
@@ -314,7 +314,7 @@ func (hs *HTTPServer) UpdateAlertNotification(c *models.ReqContext) response.Res
|
||||
return response.Error(500, "Failed to update alert notification", err)
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrAlertNotificationNotFound) {
|
||||
return response.Error(404, err.Error(), err)
|
||||
}
|
||||
@@ -330,7 +330,7 @@ func (hs *HTTPServer) UpdateAlertNotification(c *models.ReqContext) response.Res
|
||||
Id: cmd.Id,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to get alert notification", err)
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ func (hs *HTTPServer) UpdateAlertNotificationByUID(c *models.ReqContext) respons
|
||||
return response.Error(500, "Failed to update alert notification", err)
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrAlertNotificationNotFound) {
|
||||
return response.Error(404, err.Error(), nil)
|
||||
}
|
||||
@@ -362,7 +362,7 @@ func (hs *HTTPServer) UpdateAlertNotificationByUID(c *models.ReqContext) respons
|
||||
Uid: cmd.Uid,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to get alert notification", err)
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ func (hs *HTTPServer) fillWithSecureSettingsData(ctx context.Context, cmd *model
|
||||
Id: cmd.Id,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, query); err != nil {
|
||||
if err := bus.Dispatch(ctx, query); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ func (hs *HTTPServer) fillWithSecureSettingsDataByUID(ctx context.Context, cmd *
|
||||
Uid: cmd.Uid,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, query); err != nil {
|
||||
if err := bus.Dispatch(ctx, query); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ func DeleteAlertNotification(c *models.ReqContext) response.Response {
|
||||
Id: c.ParamsInt64(":notificationId"),
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrAlertNotificationNotFound) {
|
||||
return response.Error(404, err.Error(), nil)
|
||||
}
|
||||
@@ -447,7 +447,7 @@ func DeleteAlertNotificationByUID(c *models.ReqContext) response.Response {
|
||||
Uid: web.Params(c.Req)[":uid"],
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrAlertNotificationNotFound) {
|
||||
return response.Error(404, err.Error(), nil)
|
||||
}
|
||||
@@ -475,7 +475,7 @@ func NotificationTest(c *models.ReqContext) response.Response {
|
||||
SecureSettings: dto.SecureSettings,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), cmd); err != nil {
|
||||
if errors.Is(err, models.ErrSmtpNotEnabled) {
|
||||
return response.Error(412, err.Error(), err)
|
||||
}
|
||||
@@ -501,7 +501,7 @@ func PauseAlert(c *models.ReqContext) response.Response {
|
||||
result["alertId"] = alertID
|
||||
|
||||
query := models.GetAlertByIdQuery{Id: alertID}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Get Alert failed", err)
|
||||
}
|
||||
|
||||
@@ -531,7 +531,7 @@ func PauseAlert(c *models.ReqContext) response.Response {
|
||||
Paused: dto.Paused,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
return response.Error(500, "", err)
|
||||
}
|
||||
|
||||
@@ -557,7 +557,7 @@ func PauseAllAlerts(c *models.ReqContext) response.Response {
|
||||
Paused: dto.Paused,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &updateCmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &updateCmd); err != nil {
|
||||
return response.Error(500, "Failed to pause alerts", err)
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -17,7 +17,7 @@ import (
|
||||
func GetAPIKeys(c *models.ReqContext) response.Response {
|
||||
query := models.GetApiKeysQuery{OrgId: c.OrgId, IncludeExpired: c.QueryBool("includeExpired")}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to list api keys", err)
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func DeleteAPIKey(c *models.ReqContext) response.Response {
|
||||
|
||||
cmd := &models.DeleteApiKeyCommand{Id: id, OrgId: c.OrgId}
|
||||
|
||||
err := bus.DispatchCtx(c.Req.Context(), cmd)
|
||||
err := bus.Dispatch(c.Req.Context(), cmd)
|
||||
if err != nil {
|
||||
var status int
|
||||
if errors.Is(err, models.ErrApiKeyNotFound) {
|
||||
@@ -94,7 +94,7 @@ func (hs *HTTPServer) AddAPIKey(c *models.ReqContext) response.Response {
|
||||
|
||||
//Check if user and service account are in the same org
|
||||
query := models.GetUserByIdQuery{Id: cmd.ServiceAccountId}
|
||||
err = bus.DispatchCtx(c.Req.Context(), &query)
|
||||
err = bus.Dispatch(c.Req.Context(), &query)
|
||||
if err != nil {
|
||||
hs.log.Warn("Unable to link new API key to existing service account", "err", err, "query", query)
|
||||
return response.Error(500, "Unable to link new API key to existing service account", err)
|
||||
@@ -118,7 +118,7 @@ func (hs *HTTPServer) AddAPIKey(c *models.ReqContext) response.Response {
|
||||
|
||||
cmd.Key = newKeyInfo.HashedKey
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrInvalidApiKeyExpiration) {
|
||||
return response.Error(400, err.Error(), nil)
|
||||
}
|
||||
|
||||
+11
-11
@@ -34,7 +34,7 @@ func isDashboardStarredByUser(c *models.ReqContext, dashID int64) (bool, error)
|
||||
}
|
||||
|
||||
query := models.IsStarredByUserQuery{UserId: c.UserId, DashboardId: dashID}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ func (hs *HTTPServer) GetDashboard(c *models.ReqContext) response.Response {
|
||||
// lookup folder title
|
||||
if dash.FolderId > 0 {
|
||||
query := models.GetDashboardQuery{Id: dash.FolderId, OrgId: c.OrgId}
|
||||
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.ErrFolderNotFound) {
|
||||
return response.Error(404, "Folder not found", err)
|
||||
}
|
||||
@@ -196,7 +196,7 @@ func (hs *HTTPServer) GetDashboard(c *models.ReqContext) response.Response {
|
||||
|
||||
func getUserLogin(ctx context.Context, userID int64) string {
|
||||
query := models.GetUserByIdQuery{Id: userID}
|
||||
err := bus.DispatchCtx(ctx, &query)
|
||||
err := bus.Dispatch(ctx, &query)
|
||||
if err != nil {
|
||||
return anonString
|
||||
}
|
||||
@@ -212,7 +212,7 @@ func getDashboardHelper(ctx context.Context, orgID int64, id int64, uid string)
|
||||
query = models.GetDashboardQuery{Id: id, OrgId: orgID}
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, &query); err != nil {
|
||||
if err := bus.Dispatch(ctx, &query); err != nil {
|
||||
return nil, response.Error(404, "Dashboard not found", err)
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ func getDashboardHelper(ctx context.Context, orgID int64, id int64, uid string)
|
||||
func (hs *HTTPServer) DeleteDashboardBySlug(c *models.ReqContext) response.Response {
|
||||
query := models.GetDashboardsBySlugQuery{OrgId: c.OrgId, Slug: web.Params(c.Req)[":slug"]}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to retrieve dashboards by slug", err)
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ func (hs *HTTPServer) GetHomeDashboard(c *models.ReqContext) response.Response {
|
||||
prefsQuery := models.GetPreferencesWithDefaultsQuery{User: c.SignedInUser}
|
||||
homePage := hs.Cfg.HomePage
|
||||
|
||||
if err := hs.Bus.DispatchCtx(c.Req.Context(), &prefsQuery); err != nil {
|
||||
if err := hs.Bus.Dispatch(c.Req.Context(), &prefsQuery); err != nil {
|
||||
return response.Error(500, "Failed to get preferences", err)
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ func (hs *HTTPServer) GetHomeDashboard(c *models.ReqContext) response.Response {
|
||||
|
||||
if prefsQuery.Result.HomeDashboardId != 0 {
|
||||
slugQuery := models.GetDashboardRefByIdQuery{Id: prefsQuery.Result.HomeDashboardId}
|
||||
err := hs.Bus.DispatchCtx(c.Req.Context(), &slugQuery)
|
||||
err := hs.Bus.Dispatch(c.Req.Context(), &slugQuery)
|
||||
if err == nil {
|
||||
url := models.GetDashboardUrl(slugQuery.Result.Uid, slugQuery.Result.Slug)
|
||||
dashRedirect := dtos.DashboardRedirect{RedirectUri: url}
|
||||
@@ -543,7 +543,7 @@ func GetDashboardVersions(c *models.ReqContext) response.Response {
|
||||
Start: c.QueryInt("start"),
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(404, fmt.Sprintf("No versions found for dashboardId %d", dashID), err)
|
||||
}
|
||||
|
||||
@@ -582,7 +582,7 @@ func GetDashboardVersion(c *models.ReqContext) response.Response {
|
||||
Version: int(version),
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, fmt.Sprintf("Dashboard version %d not found for dashboardId %d", query.Version, dashID), err)
|
||||
}
|
||||
|
||||
@@ -671,7 +671,7 @@ func (hs *HTTPServer) RestoreDashboardVersion(c *models.ReqContext) response.Res
|
||||
}
|
||||
|
||||
versionQuery := models.GetDashboardVersionQuery{DashboardId: dash.Id, Version: apiCmd.Version, OrgId: c.OrgId}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &versionQuery); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &versionQuery); err != nil {
|
||||
return response.Error(404, "Dashboard version not found", nil)
|
||||
}
|
||||
|
||||
@@ -692,7 +692,7 @@ func (hs *HTTPServer) RestoreDashboardVersion(c *models.ReqContext) response.Res
|
||||
|
||||
func GetDashboardTags(c *models.ReqContext) {
|
||||
query := models.GetDashboardTagsQuery{OrgId: c.OrgId}
|
||||
err := bus.DispatchCtx(c.Req.Context(), &query)
|
||||
err := bus.Dispatch(c.Req.Context(), &query)
|
||||
if err != nil {
|
||||
c.JsonApiErr(500, "Failed to get tags from database", err)
|
||||
return
|
||||
|
||||
@@ -134,7 +134,7 @@ func CreateDashboardSnapshot(c *models.ReqContext) response.Response {
|
||||
metrics.MApiDashboardSnapshotCreate.Inc()
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
c.JsonApiErr(500, "Failed to create snapshot", err)
|
||||
return nil
|
||||
}
|
||||
@@ -158,7 +158,7 @@ func GetDashboardSnapshot(c *models.ReqContext) response.Response {
|
||||
|
||||
query := &models.GetDashboardSnapshotQuery{Key: key}
|
||||
|
||||
err := bus.DispatchCtx(c.Req.Context(), query)
|
||||
err := bus.Dispatch(c.Req.Context(), query)
|
||||
if err != nil {
|
||||
return response.Error(500, "Failed to get dashboard snapshot", err)
|
||||
}
|
||||
@@ -226,7 +226,7 @@ func DeleteDashboardSnapshotByDeleteKey(c *models.ReqContext) response.Response
|
||||
|
||||
query := &models.GetDashboardSnapshotQuery{DeleteKey: key}
|
||||
|
||||
err := bus.DispatchCtx(c.Req.Context(), query)
|
||||
err := bus.Dispatch(c.Req.Context(), query)
|
||||
if err != nil {
|
||||
return response.Error(500, "Failed to get dashboard snapshot", err)
|
||||
}
|
||||
@@ -240,7 +240,7 @@ func DeleteDashboardSnapshotByDeleteKey(c *models.ReqContext) response.Response
|
||||
|
||||
cmd := &models.DeleteDashboardSnapshotCommand{DeleteKey: query.Result.DeleteKey}
|
||||
|
||||
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 delete dashboard snapshot", err)
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ func DeleteDashboardSnapshot(c *models.ReqContext) response.Response {
|
||||
|
||||
query := &models.GetDashboardSnapshotQuery{Key: key}
|
||||
|
||||
err := bus.DispatchCtx(c.Req.Context(), query)
|
||||
err := bus.Dispatch(c.Req.Context(), query)
|
||||
if err != nil {
|
||||
return response.Error(500, "Failed to get dashboard snapshot", err)
|
||||
}
|
||||
@@ -288,7 +288,7 @@ func DeleteDashboardSnapshot(c *models.ReqContext) response.Response {
|
||||
|
||||
cmd := &models.DeleteDashboardSnapshotCommand{DeleteKey: query.Result.DeleteKey}
|
||||
|
||||
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 delete dashboard snapshot", err)
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ func SearchDashboardSnapshots(c *models.ReqContext) response.Response {
|
||||
SignedInUser: c.SignedInUser,
|
||||
}
|
||||
|
||||
err := bus.DispatchCtx(c.Req.Context(), &searchQuery)
|
||||
err := bus.Dispatch(c.Req.Context(), &searchQuery)
|
||||
if err != nil {
|
||||
return response.Error(500, "Search failed", err)
|
||||
}
|
||||
|
||||
+13
-13
@@ -26,7 +26,7 @@ var datasourcesLogger = log.New("datasources")
|
||||
func (hs *HTTPServer) GetDataSources(c *models.ReqContext) response.Response {
|
||||
query := models.GetDataSourcesQuery{OrgId: c.OrgId, DataSourceLimit: hs.Cfg.DataSourceLimit}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to query datasources", err)
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ func (hs *HTTPServer) GetDataSourceById(c *models.ReqContext) response.Response
|
||||
OrgId: c.OrgId,
|
||||
}
|
||||
|
||||
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.ErrDataSourceNotFound) {
|
||||
return response.Error(404, "Data source not found", nil)
|
||||
}
|
||||
@@ -136,7 +136,7 @@ func (hs *HTTPServer) DeleteDataSourceById(c *models.ReqContext) response.Respon
|
||||
|
||||
cmd := &models.DeleteDataSourceCommand{ID: id, OrgID: c.OrgId}
|
||||
|
||||
err = bus.DispatchCtx(c.Req.Context(), cmd)
|
||||
err = bus.Dispatch(c.Req.Context(), cmd)
|
||||
if err != nil {
|
||||
return response.Error(500, "Failed to delete datasource", err)
|
||||
}
|
||||
@@ -191,7 +191,7 @@ func (hs *HTTPServer) DeleteDataSourceByUID(c *models.ReqContext) response.Respo
|
||||
|
||||
cmd := &models.DeleteDataSourceCommand{UID: uid, OrgID: c.OrgId}
|
||||
|
||||
err = bus.DispatchCtx(c.Req.Context(), cmd)
|
||||
err = bus.Dispatch(c.Req.Context(), cmd)
|
||||
if err != nil {
|
||||
return response.Error(500, "Failed to delete datasource", err)
|
||||
}
|
||||
@@ -212,7 +212,7 @@ func (hs *HTTPServer) DeleteDataSourceByName(c *models.ReqContext) response.Resp
|
||||
}
|
||||
|
||||
getCmd := &models.GetDataSourceQuery{Name: name, OrgId: c.OrgId}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), getCmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), getCmd); err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceNotFound) {
|
||||
return response.Error(404, "Data source not found", nil)
|
||||
}
|
||||
@@ -224,7 +224,7 @@ func (hs *HTTPServer) DeleteDataSourceByName(c *models.ReqContext) response.Resp
|
||||
}
|
||||
|
||||
cmd := &models.DeleteDataSourceCommand{Name: name, OrgID: c.OrgId}
|
||||
err := bus.DispatchCtx(c.Req.Context(), cmd)
|
||||
err := bus.Dispatch(c.Req.Context(), cmd)
|
||||
if err != nil {
|
||||
return response.Error(500, "Failed to delete datasource", err)
|
||||
}
|
||||
@@ -260,7 +260,7 @@ func AddDataSource(c *models.ReqContext) response.Response {
|
||||
return resp
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceNameExists) || errors.Is(err, models.ErrDataSourceUidExists) {
|
||||
return response.Error(409, err.Error(), err)
|
||||
}
|
||||
@@ -294,7 +294,7 @@ func (hs *HTTPServer) UpdateDataSource(c *models.ReqContext) response.Response {
|
||||
return response.Error(500, "Failed to update datasource", err)
|
||||
}
|
||||
|
||||
err = bus.DispatchCtx(c.Req.Context(), &cmd)
|
||||
err = bus.Dispatch(c.Req.Context(), &cmd)
|
||||
if err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceUpdatingOldVersion) {
|
||||
return response.Error(409, "Datasource has already been updated by someone else. Please reload and try again", err)
|
||||
@@ -307,7 +307,7 @@ func (hs *HTTPServer) UpdateDataSource(c *models.ReqContext) response.Response {
|
||||
OrgId: c.OrgId,
|
||||
}
|
||||
|
||||
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.ErrDataSourceNotFound) {
|
||||
return response.Error(404, "Data source not found", nil)
|
||||
}
|
||||
@@ -359,7 +359,7 @@ func getRawDataSourceById(ctx context.Context, id int64, orgID int64) (*models.D
|
||||
OrgId: orgID,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, &query); err != nil {
|
||||
if err := bus.Dispatch(ctx, &query); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ func getRawDataSourceByUID(ctx context.Context, uid string, orgID int64) (*model
|
||||
OrgId: orgID,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, &query); err != nil {
|
||||
if err := bus.Dispatch(ctx, &query); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ func getRawDataSourceByUID(ctx context.Context, uid string, orgID int64) (*model
|
||||
func GetDataSourceByName(c *models.ReqContext) response.Response {
|
||||
query := models.GetDataSourceQuery{Name: web.Params(c.Req)[":name"], OrgId: c.OrgId}
|
||||
|
||||
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.ErrDataSourceNotFound) {
|
||||
return response.Error(404, "Data source not found", nil)
|
||||
}
|
||||
@@ -398,7 +398,7 @@ func GetDataSourceByName(c *models.ReqContext) response.Response {
|
||||
func GetDataSourceIdByName(c *models.ReqContext) response.Response {
|
||||
query := models.GetDataSourceQuery{Name: web.Params(c.Req)[":name"], OrgId: c.OrgId}
|
||||
|
||||
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.ErrDataSourceNotFound) {
|
||||
return response.Error(404, "Data source not found", nil)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ func (hs *HTTPServer) getFSDataSources(c *models.ReqContext, enabledPlugins Enab
|
||||
|
||||
if c.OrgId != 0 {
|
||||
query := models.GetDataSourcesQuery{OrgId: c.OrgId, DataSourceLimit: hs.Cfg.DataSourceLimit}
|
||||
err := bus.DispatchCtx(c.Req.Context(), &query)
|
||||
err := bus.Dispatch(c.Req.Context(), &query)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -30,7 +30,7 @@ func (hs *HTTPServer) getFSDataSources(c *models.ReqContext, enabledPlugins Enab
|
||||
Datasources: query.Result,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &dsFilterQuery); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &dsFilterQuery); err != nil {
|
||||
if !errors.Is(err, bus.ErrHandlerNotFound) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ func (hs *HTTPServer) databaseHealthy(ctx context.Context) bool {
|
||||
return cached.(bool)
|
||||
}
|
||||
|
||||
healthy := bus.DispatchCtx(ctx, &models.GetDBHealthQuery{}) == nil
|
||||
healthy := bus.Dispatch(ctx, &models.GetDBHealthQuery{}) == nil
|
||||
|
||||
hs.CacheService.Set(cacheKey, healthy, time.Second*5)
|
||||
return healthy
|
||||
|
||||
+2
-2
@@ -519,7 +519,7 @@ func (hs *HTTPServer) buildAdminNavLinks(c *models.ReqContext) []*dtos.NavLink {
|
||||
|
||||
func (hs *HTTPServer) setIndexViewData(c *models.ReqContext) (*dtos.IndexViewData, error) {
|
||||
hasEditPermissionInFoldersQuery := models.HasEditPermissionInFoldersQuery{SignedInUser: c.SignedInUser}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &hasEditPermissionInFoldersQuery); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &hasEditPermissionInFoldersQuery); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hasEditPerm := hasEditPermissionInFoldersQuery.Result
|
||||
@@ -532,7 +532,7 @@ func (hs *HTTPServer) setIndexViewData(c *models.ReqContext) (*dtos.IndexViewDat
|
||||
settings["dateFormats"] = hs.Cfg.DateFormats
|
||||
|
||||
prefsQuery := models.GetPreferencesWithDefaultsQuery{User: c.SignedInUser}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &prefsQuery); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &prefsQuery); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
prefs := prefsQuery.Result
|
||||
|
||||
@@ -73,7 +73,7 @@ func (user *LDAPUserDTO) FetchOrgs(ctx context.Context) error {
|
||||
q := &models.SearchOrgsQuery{}
|
||||
q.Ids = orgIds
|
||||
|
||||
if err := bus.DispatchCtx(ctx, q); err != nil {
|
||||
if err := bus.Dispatch(ctx, q); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ func (hs *HTTPServer) PostSyncUserWithLDAP(c *models.ReqContext) response.Respon
|
||||
|
||||
query := models.GetUserByIdQuery{Id: userId}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil { // validate the userId exists
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil { // validate the userId exists
|
||||
if errors.Is(err, models.ErrUserNotFound) {
|
||||
return response.Error(404, models.ErrUserNotFound.Error(), nil)
|
||||
}
|
||||
@@ -177,7 +177,7 @@ func (hs *HTTPServer) PostSyncUserWithLDAP(c *models.ReqContext) response.Respon
|
||||
|
||||
authModuleQuery := &models.GetAuthInfoQuery{UserId: query.Result.Id, AuthModule: models.AuthModuleLDAP}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), authModuleQuery); err != nil { // validate the userId comes from LDAP
|
||||
if err := bus.Dispatch(c.Req.Context(), authModuleQuery); err != nil { // validate the userId comes from LDAP
|
||||
if errors.Is(err, models.ErrUserNotFound) {
|
||||
return response.Error(404, models.ErrUserNotFound.Error(), nil)
|
||||
}
|
||||
@@ -219,7 +219,7 @@ func (hs *HTTPServer) PostSyncUserWithLDAP(c *models.ReqContext) response.Respon
|
||||
SignupAllowed: hs.Cfg.LDAPAllowSignup,
|
||||
}
|
||||
|
||||
err = bus.DispatchCtx(c.Req.Context(), upsertCmd)
|
||||
err = bus.Dispatch(c.Req.Context(), upsertCmd)
|
||||
if err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Failed to update the user", err)
|
||||
}
|
||||
@@ -308,7 +308,7 @@ func (hs *HTTPServer) GetUserFromLDAP(c *models.ReqContext) response.Response {
|
||||
}
|
||||
|
||||
cmd := &models.GetTeamsForLDAPGroupCommand{Groups: user.Groups}
|
||||
err = bus.DispatchCtx(c.Req.Context(), cmd)
|
||||
err = bus.Dispatch(c.Req.Context(), cmd)
|
||||
if err != nil && !errors.Is(err, bus.ErrHandlerNotFound) {
|
||||
return response.Error(http.StatusBadRequest, "Unable to find the teams for this user", err)
|
||||
}
|
||||
|
||||
+1
-1
@@ -207,7 +207,7 @@ func (hs *HTTPServer) LoginPost(c *models.ReqContext) response.Response {
|
||||
Cfg: hs.Cfg,
|
||||
}
|
||||
|
||||
err := bus.DispatchCtx(c.Req.Context(), authQuery)
|
||||
err := bus.Dispatch(c.Req.Context(), authQuery)
|
||||
authModule = authQuery.AuthModule
|
||||
if err != nil {
|
||||
resp = response.Error(401, "Invalid username or password", err)
|
||||
|
||||
@@ -313,7 +313,7 @@ func syncUser(
|
||||
ExternalUser: extUser,
|
||||
SignupAllowed: connect.IsSignupAllowed(),
|
||||
}
|
||||
if err := bus.DispatchCtx(ctx.Req.Context(), cmd); err != nil {
|
||||
if err := bus.Dispatch(ctx.Req.Context(), cmd); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -20,7 +20,7 @@ import (
|
||||
func GetPendingOrgInvites(c *models.ReqContext) response.Response {
|
||||
query := models.GetTempUsersQuery{OrgId: c.OrgId, Status: models.TmpUserInvitePending}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to get invites from db", err)
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func AddOrgInvite(c *models.ReqContext) response.Response {
|
||||
|
||||
// first try get existing user
|
||||
userQuery := models.GetUserByLoginQuery{LoginOrEmail: inviteDto.LoginOrEmail}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &userQuery); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &userQuery); err != nil {
|
||||
if !errors.Is(err, models.ErrUserNotFound) {
|
||||
return response.Error(500, "Failed to query db for existing user check", err)
|
||||
}
|
||||
@@ -68,7 +68,7 @@ func AddOrgInvite(c *models.ReqContext) response.Response {
|
||||
cmd.Role = inviteDto.Role
|
||||
cmd.RemoteAddr = c.Req.RemoteAddr
|
||||
|
||||
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 save invite to database", err)
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func AddOrgInvite(c *models.ReqContext) response.Response {
|
||||
},
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &emailCmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &emailCmd); err != nil {
|
||||
if errors.Is(err, models.ErrSmtpNotEnabled) {
|
||||
return response.Error(412, err.Error(), err)
|
||||
}
|
||||
@@ -95,7 +95,7 @@ func AddOrgInvite(c *models.ReqContext) response.Response {
|
||||
}
|
||||
|
||||
emailSentCmd := models.UpdateTempUserWithEmailSentCommand{Code: cmd.Result.Code}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &emailSentCmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &emailSentCmd); err != nil {
|
||||
return response.Error(500, "Failed to update invite with email sent info", err)
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ func AddOrgInvite(c *models.ReqContext) response.Response {
|
||||
func inviteExistingUserToOrg(c *models.ReqContext, user *models.User, inviteDto *dtos.AddInviteForm) response.Response {
|
||||
// user exists, add org role
|
||||
createOrgUserCmd := models.AddOrgUserCommand{OrgId: c.OrgId, UserId: user.Id, Role: inviteDto.Role}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &createOrgUserCmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &createOrgUserCmd); err != nil {
|
||||
if errors.Is(err, models.ErrOrgUserAlreadyAdded) {
|
||||
return response.Error(412, fmt.Sprintf("User %s is already added to organization", inviteDto.LoginOrEmail), err)
|
||||
}
|
||||
@@ -126,7 +126,7 @@ func inviteExistingUserToOrg(c *models.ReqContext, user *models.User, inviteDto
|
||||
},
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &emailCmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &emailCmd); err != nil {
|
||||
return response.Error(500, "Failed to send email invited_to_org", err)
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ func RevokeInvite(c *models.ReqContext) response.Response {
|
||||
// If a (pending) invite is not found, 404 is returned.
|
||||
func GetInviteInfoByCode(c *models.ReqContext) response.Response {
|
||||
query := models.GetTempUserByCodeQuery{Code: web.Params(c.Req)[":code"]}
|
||||
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.ErrTempUserNotFound) {
|
||||
return response.Error(404, "Invite not found", nil)
|
||||
}
|
||||
@@ -177,7 +177,7 @@ func (hs *HTTPServer) CompleteInvite(c *models.ReqContext) response.Response {
|
||||
}
|
||||
query := models.GetTempUserByCodeQuery{Code: completeInvite.InviteCode}
|
||||
|
||||
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.ErrTempUserNotFound) {
|
||||
return response.Error(404, "Invite not found", nil)
|
||||
}
|
||||
@@ -234,7 +234,7 @@ func (hs *HTTPServer) CompleteInvite(c *models.ReqContext) response.Response {
|
||||
func updateTempUserStatus(ctx context.Context, code string, status models.TempUserStatus) (bool, response.Response) {
|
||||
// update temp user status
|
||||
updateTmpUserCmd := models.UpdateTempUserStatusCommand{Code: code, Status: status}
|
||||
if err := bus.DispatchCtx(ctx, &updateTmpUserCmd); err != nil {
|
||||
if err := bus.Dispatch(ctx, &updateTmpUserCmd); err != nil {
|
||||
return false, response.Error(500, "Failed to update invite status", err)
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ func updateTempUserStatus(ctx context.Context, code string, status models.TempUs
|
||||
func applyUserInvite(ctx context.Context, user *models.User, invite *models.TempUserDTO, setActive bool) (bool, response.Response) {
|
||||
// add to org
|
||||
addOrgUserCmd := models.AddOrgUserCommand{OrgId: invite.OrgId, UserId: user.Id, Role: invite.Role}
|
||||
if err := bus.DispatchCtx(ctx, &addOrgUserCmd); err != nil {
|
||||
if err := bus.Dispatch(ctx, &addOrgUserCmd); err != nil {
|
||||
if !errors.Is(err, models.ErrOrgUserAlreadyAdded) {
|
||||
return false, response.Error(500, "Error while trying to create org user", err)
|
||||
}
|
||||
@@ -257,7 +257,7 @@ func applyUserInvite(ctx context.Context, user *models.User, invite *models.Temp
|
||||
|
||||
if setActive {
|
||||
// set org to active
|
||||
if err := bus.DispatchCtx(ctx, &models.SetUsingOrgCommand{OrgId: invite.OrgId, UserId: user.Id}); err != nil {
|
||||
if err := bus.Dispatch(ctx, &models.SetUsingOrgCommand{OrgId: invite.OrgId, UserId: user.Id}); err != nil {
|
||||
return false, response.Error(500, "Failed to set org as active", err)
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -27,13 +27,13 @@ func SendResetPasswordEmail(c *models.ReqContext) response.Response {
|
||||
|
||||
userQuery := models.GetUserByLoginQuery{LoginOrEmail: form.UserOrEmail}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &userQuery); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &userQuery); err != nil {
|
||||
c.Logger.Info("Requested password reset for user that was not found", "user", userQuery.LoginOrEmail)
|
||||
return response.Error(200, "Email sent", err)
|
||||
}
|
||||
|
||||
emailCmd := models.SendResetPasswordEmailCommand{User: userQuery.Result}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &emailCmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &emailCmd); err != nil {
|
||||
return response.Error(500, "Failed to send email", err)
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func ResetPassword(c *models.ReqContext) response.Response {
|
||||
}
|
||||
query := models.ValidateResetPasswordCodeQuery{Code: form.Code}
|
||||
|
||||
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.ErrInvalidEmailCode) {
|
||||
return response.Error(400, "Invalid or expired reset password code", nil)
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func ResetPassword(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)
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -13,7 +13,7 @@ import (
|
||||
func ValidateOrgPlaylist(c *models.ReqContext) {
|
||||
id := c.ParamsInt64(":id")
|
||||
query := models.GetPlaylistByIdQuery{Id: id}
|
||||
err := bus.DispatchCtx(c.Req.Context(), &query)
|
||||
err := bus.Dispatch(c.Req.Context(), &query)
|
||||
|
||||
if err != nil {
|
||||
c.JsonApiErr(404, "Playlist not found", err)
|
||||
@@ -45,7 +45,7 @@ func SearchPlaylists(c *models.ReqContext) response.Response {
|
||||
OrgId: c.OrgId,
|
||||
}
|
||||
|
||||
err := bus.DispatchCtx(c.Req.Context(), &searchQuery)
|
||||
err := bus.Dispatch(c.Req.Context(), &searchQuery)
|
||||
if err != nil {
|
||||
return response.Error(500, "Search failed", err)
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func GetPlaylist(c *models.ReqContext) response.Response {
|
||||
id := c.ParamsInt64(":id")
|
||||
cmd := models.GetPlaylistByIdQuery{Id: id}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
return response.Error(500, "Playlist not found", err)
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ func LoadPlaylistItemDTOs(ctx context.Context, id int64) ([]models.PlaylistItemD
|
||||
|
||||
func LoadPlaylistItems(ctx context.Context, id int64) ([]models.PlaylistItem, error) {
|
||||
itemQuery := models.GetPlaylistItemsByIdQuery{PlaylistId: id}
|
||||
if err := bus.DispatchCtx(ctx, &itemQuery); err != nil {
|
||||
if err := bus.Dispatch(ctx, &itemQuery); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func DeletePlaylist(c *models.ReqContext) response.Response {
|
||||
id := c.ParamsInt64(":id")
|
||||
|
||||
cmd := models.DeletePlaylistCommand{Id: id, OrgId: c.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 delete playlist", err)
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ func CreatePlaylist(c *models.ReqContext) response.Response {
|
||||
}
|
||||
cmd.OrgId = c.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 create playlist", err)
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ func UpdatePlaylist(c *models.ReqContext) response.Response {
|
||||
cmd.OrgId = c.OrgId
|
||||
cmd.Id = c.ParamsInt64(":id")
|
||||
|
||||
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 save playlist", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ func populateDashboardsByID(ctx context.Context, dashboardByIDs []int64, dashboa
|
||||
|
||||
if len(dashboardByIDs) > 0 {
|
||||
dashboardQuery := models.GetDashboardsQuery{DashboardIds: dashboardByIDs}
|
||||
if err := bus.DispatchCtx(ctx, &dashboardQuery); err != nil {
|
||||
if err := bus.Dispatch(ctx, &dashboardQuery); err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func populateDashboardsByTag(ctx context.Context, orgID int64, signedInUser *mod
|
||||
OrgId: orgID,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, &searchQuery); err == nil {
|
||||
if err := bus.Dispatch(ctx, &searchQuery); err == nil {
|
||||
for _, item := range searchQuery.Result {
|
||||
result = append(result, dtos.PlaylistDashboard{
|
||||
Id: item.ID,
|
||||
|
||||
@@ -25,7 +25,7 @@ func NewApiPluginProxy(ctx *models.ReqContext, proxyPath string, route *plugins.
|
||||
appID string, cfg *setting.Cfg, secretsService secrets.Service) *httputil.ReverseProxy {
|
||||
director := func(req *http.Request) {
|
||||
query := models.GetPluginSettingByIdQuery{OrgId: ctx.OrgId, PluginId: appID}
|
||||
if err := bus.DispatchCtx(ctx.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(ctx.Req.Context(), &query); err != nil {
|
||||
ctx.JsonApiErr(500, "Failed to fetch plugin settings", err)
|
||||
return
|
||||
}
|
||||
|
||||
+2
-2
@@ -141,7 +141,7 @@ func (hs *HTTPServer) GetPluginSettingByID(c *models.ReqContext) response.Respon
|
||||
}
|
||||
|
||||
query := models.GetPluginSettingByIdQuery{PluginId: pluginID, OrgId: c.OrgId}
|
||||
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.ErrPluginSettingNotFound) {
|
||||
return response.Error(500, "Failed to get login settings", nil)
|
||||
}
|
||||
@@ -167,7 +167,7 @@ func (hs *HTTPServer) UpdatePluginSetting(c *models.ReqContext) response.Respons
|
||||
|
||||
cmd.OrgId = c.OrgId
|
||||
cmd.PluginId = pluginID
|
||||
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 plugin setting", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ func SetHomeDashboard(c *models.ReqContext) response.Response {
|
||||
cmd.UserId = c.UserId
|
||||
cmd.OrgId = c.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 set home dashboard", err)
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -58,7 +58,7 @@ func GetUserQuotas(c *models.ReqContext) response.Response {
|
||||
}
|
||||
query := models.GetUserQuotasQuery{UserId: c.ParamsInt64(":id")}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to get org quotas", err)
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func UpdateUserQuota(c *models.ReqContext) response.Response {
|
||||
return response.Error(404, "Invalid quota target", nil)
|
||||
}
|
||||
|
||||
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 org quotas", err)
|
||||
}
|
||||
return response.Success("Organization quota updated")
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ func Search(c *models.ReqContext) response.Response {
|
||||
Sort: sort,
|
||||
}
|
||||
|
||||
err := bus.DispatchCtx(c.Req.Context(), &searchQuery)
|
||||
err := bus.Dispatch(c.Req.Context(), &searchQuery)
|
||||
if err != nil {
|
||||
return response.Error(500, "Search failed", err)
|
||||
}
|
||||
|
||||
+4
-4
@@ -35,7 +35,7 @@ func SignUp(c *models.ReqContext) response.Response {
|
||||
}
|
||||
|
||||
existing := models.GetUserByLoginQuery{LoginOrEmail: form.Email}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &existing); err == nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &existing); err == nil {
|
||||
return response.Error(422, "User with same email address already exists", nil)
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func SignUp(c *models.ReqContext) response.Response {
|
||||
}
|
||||
cmd.RemoteAddr = c.Req.RemoteAddr
|
||||
|
||||
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 create signup", err)
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ func (hs *HTTPServer) SignUpStep2(c *models.ReqContext) response.Response {
|
||||
|
||||
// check for pending invites
|
||||
invitesQuery := models.GetTempUsersQuery{Email: form.Email, Status: models.TmpUserInvitePending}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &invitesQuery); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &invitesQuery); err != nil {
|
||||
return response.Error(500, "Failed to query database for invites", err)
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ func (hs *HTTPServer) SignUpStep2(c *models.ReqContext) response.Response {
|
||||
func verifyUserSignUpEmail(ctx context.Context, email string, code string) (bool, response.Response) {
|
||||
query := models.GetTempUserByCodeQuery{Code: code}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, &query); err != nil {
|
||||
if err := bus.Dispatch(ctx, &query); err != nil {
|
||||
if errors.Is(err, models.ErrTempUserNotFound) {
|
||||
return false, response.Error(404, "Invalid email verification code", nil)
|
||||
}
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ func StarDashboard(c *models.ReqContext) response.Response {
|
||||
return response.Error(400, "Missing dashboard id", nil)
|
||||
}
|
||||
|
||||
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 star dashboard", err)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func UnstarDashboard(c *models.ReqContext) response.Response {
|
||||
return response.Error(400, "Missing dashboard id", nil)
|
||||
}
|
||||
|
||||
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 unstar dashboard", err)
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -65,7 +65,7 @@ func (hs *HTTPServer) UpdateTeam(c *models.ReqContext) response.Response {
|
||||
return response.Error(403, "Not allowed to update team", err)
|
||||
}
|
||||
|
||||
if err := hs.Bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := hs.Bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrTeamNameTaken) {
|
||||
return response.Error(400, "Team name taken", err)
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func (hs *HTTPServer) DeleteTeamByID(c *models.ReqContext) response.Response {
|
||||
return response.Error(403, "Not allowed to delete team", err)
|
||||
}
|
||||
|
||||
if err := hs.Bus.DispatchCtx(c.Req.Context(), &models.DeleteTeamCommand{OrgId: orgId, Id: teamId}); err != nil {
|
||||
if err := hs.Bus.Dispatch(c.Req.Context(), &models.DeleteTeamCommand{OrgId: orgId, Id: teamId}); err != nil {
|
||||
if errors.Is(err, models.ErrTeamNotFound) {
|
||||
return response.Error(404, "Failed to delete Team. ID not found", nil)
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func (hs *HTTPServer) SearchTeams(c *models.ReqContext) response.Response {
|
||||
HiddenUsers: hs.Cfg.HiddenUsers,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to search Teams", err)
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ func (hs *HTTPServer) GetTeamByID(c *models.ReqContext) response.Response {
|
||||
HiddenUsers: hs.Cfg.HiddenUsers,
|
||||
}
|
||||
|
||||
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.ErrTeamNotFound) {
|
||||
return response.Error(404, "Team not found", err)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
func (hs *HTTPServer) GetTeamMembers(c *models.ReqContext) response.Response {
|
||||
query := models.GetTeamMembersQuery{OrgId: c.OrgId, TeamId: c.ParamsInt64(":teamId")}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to get Team Members", err)
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ func (hs *HTTPServer) UpdateTeamMember(c *models.ReqContext) response.Response {
|
||||
cmd.UserId = c.ParamsInt64(":userId")
|
||||
cmd.OrgId = orgId
|
||||
|
||||
if err := hs.Bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := hs.Bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrTeamMemberNotFound) {
|
||||
return response.Error(404, "Team member not found.", nil)
|
||||
}
|
||||
@@ -118,7 +118,7 @@ func (hs *HTTPServer) RemoveTeamMember(c *models.ReqContext) response.Response {
|
||||
protectLastAdmin = true
|
||||
}
|
||||
|
||||
if err := hs.Bus.DispatchCtx(c.Req.Context(), &models.RemoveTeamMemberCommand{OrgId: orgId, TeamId: teamId, UserId: userId, ProtectLastAdmin: protectLastAdmin}); err != nil {
|
||||
if err := hs.Bus.Dispatch(c.Req.Context(), &models.RemoveTeamMemberCommand{OrgId: orgId, TeamId: teamId, UserId: userId, ProtectLastAdmin: protectLastAdmin}); err != nil {
|
||||
if errors.Is(err, models.ErrTeamNotFound) {
|
||||
return response.Error(404, "Team not found", nil)
|
||||
}
|
||||
|
||||
+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)
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ func (hs *HTTPServer) RevokeUserAuthToken(c *models.ReqContext) response.Respons
|
||||
func (hs *HTTPServer) logoutUserFromAllDevicesInternal(ctx context.Context, userID int64) response.Response {
|
||||
userQuery := models.GetUserByIdQuery{Id: userID}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, &userQuery); err != nil {
|
||||
if err := bus.Dispatch(ctx, &userQuery); err != nil {
|
||||
if errors.Is(err, models.ErrUserNotFound) {
|
||||
return response.Error(404, "User not found", err)
|
||||
}
|
||||
@@ -52,7 +52,7 @@ func (hs *HTTPServer) logoutUserFromAllDevicesInternal(ctx context.Context, user
|
||||
func (hs *HTTPServer) getUserAuthTokensInternal(c *models.ReqContext, userID int64) response.Response {
|
||||
userQuery := models.GetUserByIdQuery{Id: userID}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &userQuery); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &userQuery); err != nil {
|
||||
if errors.Is(err, models.ErrUserNotFound) {
|
||||
return response.Error(404, "User not found", err)
|
||||
}
|
||||
@@ -119,7 +119,7 @@ func (hs *HTTPServer) getUserAuthTokensInternal(c *models.ReqContext, userID int
|
||||
func (hs *HTTPServer) revokeUserAuthTokenInternal(c *models.ReqContext, userID int64, cmd models.RevokeAuthTokenCmd) response.Response {
|
||||
userQuery := models.GetUserByIdQuery{Id: userID}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &userQuery); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &userQuery); err != nil {
|
||||
if errors.Is(err, models.ErrUserNotFound) {
|
||||
return response.Error(404, "User not found", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user