diff --git a/pkg/api/alerting.go b/pkg/api/alerting.go index 64f80598821..0cd00d3b015 100644 --- a/pkg/api/alerting.go +++ b/pkg/api/alerting.go @@ -261,6 +261,10 @@ func UpdateAlertNotification(c *m.ReqContext, cmd m.UpdateAlertNotificationComma return Error(500, "Failed to update alert notification", err) } + if cmd.Result == nil { + return Error(404, "Alert notification not found", nil) + } + return JSON(200, dtos.NewAlertNotification(cmd.Result)) } @@ -272,6 +276,10 @@ func UpdateAlertNotificationByUID(c *m.ReqContext, cmd m.UpdateAlertNotification return Error(500, "Failed to update alert notification", err) } + if cmd.Result == nil { + return Error(404, "Alert notification not found", nil) + } + return JSON(200, dtos.NewAlertNotification(cmd.Result)) } diff --git a/pkg/models/alert_notifications.go b/pkg/models/alert_notifications.go index 1d445b5eb72..ccfd6ee84db 100644 --- a/pkg/models/alert_notifications.go +++ b/pkg/models/alert_notifications.go @@ -39,7 +39,7 @@ type AlertNotification struct { } type CreateAlertNotificationCommand struct { - Uid string `json:"-"` + Uid string `json:"uid"` Name string `json:"name" binding:"Required"` Type string `json:"type" binding:"Required"` SendReminder bool `json:"sendReminder"` diff --git a/pkg/services/sqlstore/alert_notification.go b/pkg/services/sqlstore/alert_notification.go index 7c376419161..898ab9ebc66 100644 --- a/pkg/services/sqlstore/alert_notification.go +++ b/pkg/services/sqlstore/alert_notification.go @@ -382,6 +382,8 @@ func UpdateAlertNotificationWithUid(cmd *m.UpdateAlertNotificationWithUidCommand return err } + cmd.Result = updateNotification.Result + return nil }