Skip to content

Commit

Permalink
fix: edge record notify
Browse files Browse the repository at this point in the history
  • Loading branch information
710leo committed Aug 13, 2024
1 parent bfea83a commit 7c91e51
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 9 additions & 1 deletion alert/sender/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,16 @@ func NotifyRecord(ctx *ctx.Context, evt *models.AlertCurEvent, channel, target,
noti.SetDetails(string(res))
}

if !ctx.IsCenter {
_, err := poster.PostByUrlsWithResp[int64](ctx, "/v1/n9e/notify-record", noti)
if err != nil {
logger.Errorf("add noti:%v failed, err: %v", noti, err)
}
return
}

if err := noti.Add(ctx); err != nil {
logger.Errorf("Add noti failed, err: %v", err)
logger.Errorf("add noti:%v failed, err: %v", noti, err)
}
}

Expand Down
1 change: 1 addition & 0 deletions center/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ func (rt *Router) Config(r *gin.Engine) {

service.GET("/targets-of-alert-rule", rt.targetsOfAlertRule)

service.POST("/notify-record", rt.notificationRecordAdd)
}
}

Expand Down
9 changes: 9 additions & 0 deletions center/router/router_notification_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ type Record struct {
Detail string `json:"detail"`
}

// notificationRecordAdd
func (rt *Router) notificationRecordAdd(c *gin.Context) {
var req models.NotificaitonRecord
ginx.BindJSON(c, &req)
err := req.Add(rt.Ctx)

ginx.NewRender(c).Data(req.Id, err)
}

func (rt *Router) notificationRecordList(c *gin.Context) {
eid := ginx.UrlParamInt64(c, "eid")
lst, err := models.NotificaitonRecordsGetByEventId(rt.Ctx, eid)
Expand Down

0 comments on commit 7c91e51

Please sign in to comment.