Commit be0d4714 by Matthew McGinn

properly parse & pass upload image bool from config

parent 122e2b5c
...@@ -74,6 +74,7 @@ func NewSlackNotifier(model *m.AlertNotification) (alerting.Notifier, error) { ...@@ -74,6 +74,7 @@ func NewSlackNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
recipient := model.Settings.Get("recipient").MustString() recipient := model.Settings.Get("recipient").MustString()
mention := model.Settings.Get("mention").MustString() mention := model.Settings.Get("mention").MustString()
token := model.Settings.Get("token").MustString() token := model.Settings.Get("token").MustString()
uploadImage := model.Settings.Get("uploadImage").MustBool(true)
return &SlackNotifier{ return &SlackNotifier{
NotifierBase: NewNotifierBase(model.Id, model.IsDefault, model.Name, model.Type, model.Settings), NotifierBase: NewNotifierBase(model.Id, model.IsDefault, model.Name, model.Type, model.Settings),
...@@ -81,6 +82,7 @@ func NewSlackNotifier(model *m.AlertNotification) (alerting.Notifier, error) { ...@@ -81,6 +82,7 @@ func NewSlackNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
Recipient: recipient, Recipient: recipient,
Mention: mention, Mention: mention,
Token: token, Token: token,
Upload: uploadImage,
log: log.New("alerting.notifier.slack"), log: log.New("alerting.notifier.slack"),
}, nil }, nil
} }
...@@ -91,6 +93,7 @@ type SlackNotifier struct { ...@@ -91,6 +93,7 @@ type SlackNotifier struct {
Recipient string Recipient string
Mention string Mention string
Token string Token string
Upload bool
log log.Logger log log.Logger
} }
...@@ -162,7 +165,7 @@ func (this *SlackNotifier) Notify(evalContext *alerting.EvalContext) error { ...@@ -162,7 +165,7 @@ func (this *SlackNotifier) Notify(evalContext *alerting.EvalContext) error {
this.log.Error("Failed to send slack notification", "error", err, "webhook", this.Name) this.log.Error("Failed to send slack notification", "error", err, "webhook", this.Name)
return err return err
} }
if this.Token != "" { if this.Token != "" && this.UploadImage {
err = SlackFileUpload(evalContext, this.log, "https://slack.com/api/files.upload", this.Recipient, this.Token) err = SlackFileUpload(evalContext, this.log, "https://slack.com/api/files.upload", this.Recipient, this.Token)
if err != nil { if err != nil {
return err return err
......
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