fix(http): lookup task before clearing it's id from the notification rule

pull/15278/head
Michael Desa 2019-09-25 16:33:05 -04:00
parent 2bb8418575
commit ca937eaf11
No known key found for this signature in database
GPG Key ID: 87002651EC5DFFE6
1 changed files with 7 additions and 7 deletions

View File

@ -178,6 +178,12 @@ type notificationRulesResponse struct {
}
func (h *NotificationRuleHandler) newNotificationRuleResponse(ctx context.Context, nr influxdb.NotificationRule, labels []*influxdb.Label) (*notificationRuleResponse, error) {
// TODO(desa): this should be handled in the rule service and not exposed in http land, but is currently blocking the FE. https://github.com/influxdata/influxdb/issues/15259
t, err := h.TaskService.FindTaskByID(ctx, nr.GetTaskID())
if err != nil {
return nil, err
}
nr.ClearPrivateData()
res := &notificationRuleResponse{
NotificationRule: nr,
@ -188,19 +194,13 @@ func (h *NotificationRuleHandler) newNotificationRuleResponse(ctx context.Contex
Owners: fmt.Sprintf("/api/v2/notificationRules/%s/owners", nr.GetID()),
},
Labels: []influxdb.Label{},
Status: t.Status,
}
for _, l := range labels {
res.Labels = append(res.Labels, *l)
}
t, err := h.TaskService.FindTaskByID(ctx, nr.GetTaskID())
if err != nil {
return nil, err
}
res.Status = t.Status
return res, nil
}