Commit 6a030b2e by Joseph Weigl

Change empty string checks and improve logging

parent 7284db0e
...@@ -115,7 +115,7 @@ func (this *HipChatNotifier) Notify(evalContext *alerting.EvalContext) error { ...@@ -115,7 +115,7 @@ func (this *HipChatNotifier) Notify(evalContext *alerting.EvalContext) error {
message += " " + evalContext.Rule.Message message += " " + evalContext.Rule.Message
} }
if len(message) < 1 { if message == "" {
message = evalContext.GetNotificationTitle() + " in state " + evalContext.GetStateModel().Text message = evalContext.GetNotificationTitle() + " in state " + evalContext.GetStateModel().Text
} }
...@@ -143,7 +143,7 @@ func (this *HipChatNotifier) Notify(evalContext *alerting.EvalContext) error { ...@@ -143,7 +143,7 @@ func (this *HipChatNotifier) Notify(evalContext *alerting.EvalContext) error {
"date": evalContext.EndTime.Unix(), "date": evalContext.EndTime.Unix(),
"attributes": attributes, "attributes": attributes,
} }
if len(evalContext.ImagePublicUrl) > 0 { if evalContext.ImagePublicUrl != "" {
card["thumbnail"] = map[string]interface{}{ card["thumbnail"] = map[string]interface{}{
"url": evalContext.ImagePublicUrl, "url": evalContext.ImagePublicUrl,
"url@2x": evalContext.ImagePublicUrl, "url@2x": evalContext.ImagePublicUrl,
...@@ -162,7 +162,7 @@ func (this *HipChatNotifier) Notify(evalContext *alerting.EvalContext) error { ...@@ -162,7 +162,7 @@ func (this *HipChatNotifier) Notify(evalContext *alerting.EvalContext) error {
hipUrl := fmt.Sprintf("%s/v2/room/%s/notification?auth_token=%s", this.Url, this.RoomId, this.ApiKey) hipUrl := fmt.Sprintf("%s/v2/room/%s/notification?auth_token=%s", this.Url, this.RoomId, this.ApiKey)
data, _ := json.Marshal(&body) data, _ := json.Marshal(&body)
this.log.Debug(string(data)) this.log.Info("Request payload", "json", string(data))
cmd := &models.SendWebhookSync{Url: hipUrl, Body: string(data)} cmd := &models.SendWebhookSync{Url: hipUrl, Body: string(data)}
if err := bus.DispatchCtx(evalContext.Ctx, cmd); err != nil { if err := bus.DispatchCtx(evalContext.Ctx, cmd); err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment