2016-12-30 06:57:12 -06:00
|
|
|
package notifiers
|
|
|
|
|
|
|
|
import (
|
2017-11-22 09:40:42 -06:00
|
|
|
"bytes"
|
2016-12-30 06:57:12 -06:00
|
|
|
"fmt"
|
2018-04-23 12:28:54 -05:00
|
|
|
"io"
|
|
|
|
"mime/multipart"
|
|
|
|
"os"
|
|
|
|
|
2016-12-30 06:57:12 -06:00
|
|
|
"github.com/grafana/grafana/pkg/bus"
|
|
|
|
"github.com/grafana/grafana/pkg/log"
|
|
|
|
m "github.com/grafana/grafana/pkg/models"
|
|
|
|
"github.com/grafana/grafana/pkg/services/alerting"
|
|
|
|
)
|
|
|
|
|
2018-03-05 09:26:35 -06:00
|
|
|
const (
|
|
|
|
captionLengthLimit = 200
|
|
|
|
)
|
|
|
|
|
2016-12-30 06:57:12 -06:00
|
|
|
var (
|
2018-04-27 15:14:36 -05:00
|
|
|
telegramApiUrl = "https://api.telegram.org/bot%s/%s"
|
2016-12-30 06:57:12 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2017-01-06 05:04:25 -06:00
|
|
|
alerting.RegisterNotifier(&alerting.NotifierPlugin{
|
|
|
|
Type: "telegram",
|
|
|
|
Name: "Telegram",
|
|
|
|
Description: "Sends notifications to Telegram",
|
2017-01-30 23:23:19 -06:00
|
|
|
Factory: NewTelegramNotifier,
|
2017-01-06 05:04:25 -06:00
|
|
|
OptionsTemplate: `
|
|
|
|
<h3 class="page-heading">Telegram API settings</h3>
|
|
|
|
<div class="gf-form">
|
|
|
|
<span class="gf-form-label width-9">BOT API Token</span>
|
|
|
|
<input type="text" required
|
|
|
|
class="gf-form-input"
|
|
|
|
ng-model="ctrl.model.settings.bottoken"
|
|
|
|
placeholder="Telegram BOT API Token"></input>
|
|
|
|
</div>
|
|
|
|
<div class="gf-form">
|
|
|
|
<span class="gf-form-label width-9">Chat ID</span>
|
|
|
|
<input type="text" required
|
|
|
|
class="gf-form-input"
|
|
|
|
ng-model="ctrl.model.settings.chatid"
|
|
|
|
data-placement="right">
|
|
|
|
</input>
|
|
|
|
<info-popover mode="right-absolute">
|
|
|
|
Integer Telegram Chat Identifier
|
|
|
|
</info-popover>
|
|
|
|
</div>
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
|
2016-12-30 06:57:12 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type TelegramNotifier struct {
|
|
|
|
NotifierBase
|
2017-11-22 09:41:36 -06:00
|
|
|
BotToken string
|
|
|
|
ChatID string
|
|
|
|
UploadImage bool
|
|
|
|
log log.Logger
|
2016-12-30 06:57:12 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewTelegramNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
|
|
|
|
if model.Settings == nil {
|
|
|
|
return nil, alerting.ValidationError{Reason: "No Settings Supplied"}
|
|
|
|
}
|
|
|
|
|
|
|
|
botToken := model.Settings.Get("bottoken").MustString()
|
|
|
|
chatId := model.Settings.Get("chatid").MustString()
|
2017-11-22 09:41:36 -06:00
|
|
|
uploadImage := model.Settings.Get("uploadImage").MustBool()
|
2016-12-30 06:57:12 -06:00
|
|
|
|
|
|
|
if botToken == "" {
|
|
|
|
return nil, alerting.ValidationError{Reason: "Could not find Bot Token in settings"}
|
|
|
|
}
|
|
|
|
|
|
|
|
if chatId == "" {
|
|
|
|
return nil, alerting.ValidationError{Reason: "Could not find Chat Id in settings"}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &TelegramNotifier{
|
2018-06-05 03:27:29 -05:00
|
|
|
NotifierBase: NewNotifierBase(model),
|
2016-12-30 06:57:12 -06:00
|
|
|
BotToken: botToken,
|
|
|
|
ChatID: chatId,
|
2017-11-22 09:41:36 -06:00
|
|
|
UploadImage: uploadImage,
|
2016-12-30 06:57:12 -06:00
|
|
|
log: log.New("alerting.notifier.telegram"),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2017-11-22 09:41:36 -06:00
|
|
|
func (this *TelegramNotifier) buildMessage(evalContext *alerting.EvalContext, sendImageInline bool) *m.SendWebhookSync {
|
|
|
|
if sendImageInline {
|
2018-03-05 09:26:35 -06:00
|
|
|
cmd, err := this.buildMessageInlineImage(evalContext)
|
|
|
|
if err == nil {
|
|
|
|
return cmd
|
2017-11-22 09:41:36 -06:00
|
|
|
}
|
Outdent code after if block that ends with return (golint)
This commit fixes the following golint warnings:
pkg/bus/bus.go:64:9: if block ends with a return statement, so drop this else and outdent its block
pkg/bus/bus.go:84:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:137:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:177:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:183:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:199:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:208:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/components/dynmap/dynmap.go:236:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:242:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:257:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:263:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:278:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:284:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:299:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:331:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:350:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:356:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:366:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:390:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:396:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:405:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:427:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:433:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:442:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:459:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:465:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:474:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:491:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:497:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:506:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:523:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:529:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:538:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:555:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:561:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:570:12: if block ends with a return statement, so drop this else and outdent its block
pkg/login/ldap.go:55:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/login/ldap_test.go:372:10: if block ends with a return statement, so drop this else and outdent its block
pkg/middleware/middleware_test.go:213:12: if block ends with a return statement, so drop this else and outdent its block
pkg/plugins/dashboard_importer.go:153:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/dashboards_updater.go:39:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/dashboards_updater.go:121:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/plugins.go:210:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/plugins.go:235:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/eval_context.go:111:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifier.go:92:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifier.go:98:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifier.go:122:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/rule.go:108:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/rule.go:118:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/rule.go:121:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifiers/telegram.go:94:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/annotation.go:34:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/sqlstore/annotation.go:99:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/sqlstore/dashboard_test.go:107:13: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/plugin_setting.go:78:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/preferences.go:91:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/user.go:50:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/migrator/migrator.go:106:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/sqlstore/migrator/postgres_dialect.go:48:10: if block ends with a return statement, so drop this else and outdent its block
pkg/tsdb/time_range.go:59:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/tsdb/time_range.go:67:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/tsdb/cloudwatch/metric_find_query.go:225:9: if block ends with a return statement, so drop this else and outdent its block
pkg/util/filepath.go:68:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
2018-04-27 15:42:49 -05:00
|
|
|
this.log.Error("Could not generate Telegram message with inline image.", "err", err)
|
2017-11-22 09:41:36 -06:00
|
|
|
}
|
2016-12-30 06:57:12 -06:00
|
|
|
|
2018-03-05 09:26:35 -06:00
|
|
|
return this.buildMessageLinkedImage(evalContext)
|
|
|
|
}
|
2017-11-22 09:41:36 -06:00
|
|
|
|
2018-03-05 09:26:35 -06:00
|
|
|
func (this *TelegramNotifier) buildMessageLinkedImage(evalContext *alerting.EvalContext) *m.SendWebhookSync {
|
|
|
|
message := fmt.Sprintf("<b>%s</b>\nState: %s\nMessage: %s\n", evalContext.GetNotificationTitle(), evalContext.Rule.Name, evalContext.Rule.Message)
|
2016-12-30 06:57:12 -06:00
|
|
|
|
|
|
|
ruleUrl, err := evalContext.GetRuleUrl()
|
|
|
|
if err == nil {
|
|
|
|
message = message + fmt.Sprintf("URL: %s\n", ruleUrl)
|
|
|
|
}
|
2017-11-22 09:41:36 -06:00
|
|
|
|
2018-03-05 09:26:35 -06:00
|
|
|
if evalContext.ImagePublicUrl != "" {
|
|
|
|
message = message + fmt.Sprintf("Image: %s\n", evalContext.ImagePublicUrl)
|
2017-01-31 07:47:14 -06:00
|
|
|
}
|
2017-04-19 02:53:23 -05:00
|
|
|
|
2018-03-05 09:26:35 -06:00
|
|
|
metrics := generateMetricsMessage(evalContext)
|
|
|
|
if metrics != "" {
|
|
|
|
message = message + fmt.Sprintf("\n<i>Metrics:</i>%s", metrics)
|
2017-04-19 02:53:23 -05:00
|
|
|
}
|
2017-11-22 09:41:36 -06:00
|
|
|
|
2018-03-05 09:26:35 -06:00
|
|
|
cmd := this.generateTelegramCmd(message, "text", "sendMessage", func(w *multipart.Writer) {
|
|
|
|
fw, _ := w.CreateFormField("parse_mode")
|
|
|
|
fw.Write([]byte("html"))
|
|
|
|
})
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *TelegramNotifier) buildMessageInlineImage(evalContext *alerting.EvalContext) (*m.SendWebhookSync, error) {
|
|
|
|
var imageFile *os.File
|
|
|
|
var err error
|
|
|
|
|
|
|
|
imageFile, err = os.Open(evalContext.ImageOnDiskPath)
|
|
|
|
defer imageFile.Close()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2017-04-19 02:53:23 -05:00
|
|
|
}
|
|
|
|
|
2018-03-05 09:26:35 -06:00
|
|
|
ruleUrl, err := evalContext.GetRuleUrl()
|
2018-04-23 12:28:54 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2018-03-05 09:26:35 -06:00
|
|
|
|
|
|
|
metrics := generateMetricsMessage(evalContext)
|
|
|
|
message := generateImageCaption(evalContext, ruleUrl, metrics)
|
|
|
|
|
|
|
|
cmd := this.generateTelegramCmd(message, "caption", "sendPhoto", func(w *multipart.Writer) {
|
|
|
|
fw, _ := w.CreateFormFile("photo", evalContext.ImageOnDiskPath)
|
|
|
|
io.Copy(fw, imageFile)
|
|
|
|
})
|
|
|
|
return cmd, nil
|
|
|
|
}
|
2017-11-22 09:41:36 -06:00
|
|
|
|
2018-03-05 09:26:35 -06:00
|
|
|
func (this *TelegramNotifier) generateTelegramCmd(message string, messageField string, apiAction string, extraConf func(writer *multipart.Writer)) *m.SendWebhookSync {
|
|
|
|
var body bytes.Buffer
|
2017-11-22 09:40:42 -06:00
|
|
|
w := multipart.NewWriter(&body)
|
2018-03-05 09:26:35 -06:00
|
|
|
|
2017-11-22 09:40:42 -06:00
|
|
|
fw, _ := w.CreateFormField("chat_id")
|
|
|
|
fw.Write([]byte(this.ChatID))
|
2016-12-30 06:57:12 -06:00
|
|
|
|
2018-03-05 09:26:35 -06:00
|
|
|
fw, _ = w.CreateFormField(messageField)
|
|
|
|
fw.Write([]byte(message))
|
2016-12-30 06:57:12 -06:00
|
|
|
|
2018-03-05 09:26:35 -06:00
|
|
|
extraConf(w)
|
2017-11-22 09:40:42 -06:00
|
|
|
|
|
|
|
w.Close()
|
|
|
|
|
2018-03-05 09:26:35 -06:00
|
|
|
this.log.Info("Sending telegram notification", "chat_id", this.ChatID, "bot_token", this.BotToken, "apiAction", apiAction)
|
|
|
|
url := fmt.Sprintf(telegramApiUrl, this.BotToken, apiAction)
|
2017-11-22 09:41:36 -06:00
|
|
|
|
2016-12-30 06:57:12 -06:00
|
|
|
cmd := &m.SendWebhookSync{
|
|
|
|
Url: url,
|
2017-11-22 09:40:42 -06:00
|
|
|
Body: body.String(),
|
2016-12-30 06:57:12 -06:00
|
|
|
HttpMethod: "POST",
|
2017-11-22 09:40:42 -06:00
|
|
|
HttpHeader: map[string]string{
|
|
|
|
"Content-Type": w.FormDataContentType(),
|
|
|
|
},
|
2016-12-30 06:57:12 -06:00
|
|
|
}
|
2017-11-22 09:41:36 -06:00
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
2018-03-05 09:26:35 -06:00
|
|
|
func generateMetricsMessage(evalContext *alerting.EvalContext) string {
|
|
|
|
metrics := ""
|
|
|
|
fieldLimitCount := 4
|
|
|
|
for index, evt := range evalContext.EvalMatches {
|
|
|
|
metrics += fmt.Sprintf("\n%s: %s", evt.Metric, evt.Value)
|
|
|
|
if index > fieldLimitCount {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return metrics
|
|
|
|
}
|
|
|
|
|
|
|
|
func generateImageCaption(evalContext *alerting.EvalContext, ruleUrl string, metrics string) string {
|
|
|
|
message := evalContext.GetNotificationTitle()
|
|
|
|
|
|
|
|
if len(evalContext.Rule.Message) > 0 {
|
|
|
|
message = fmt.Sprintf("%s\nMessage: %s", message, evalContext.Rule.Message)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(message) > captionLengthLimit {
|
|
|
|
message = message[0:captionLengthLimit]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(ruleUrl) > 0 {
|
|
|
|
urlLine := fmt.Sprintf("\nURL: %s", ruleUrl)
|
|
|
|
message = appendIfPossible(message, urlLine, captionLengthLimit)
|
|
|
|
}
|
|
|
|
|
|
|
|
if metrics != "" {
|
|
|
|
metricsLines := fmt.Sprintf("\n\nMetrics:%s", metrics)
|
|
|
|
message = appendIfPossible(message, metricsLines, captionLengthLimit)
|
|
|
|
}
|
|
|
|
|
|
|
|
return message
|
|
|
|
}
|
2018-03-15 04:22:51 -05:00
|
|
|
|
2018-03-05 09:26:35 -06:00
|
|
|
func appendIfPossible(message string, extra string, sizeLimit int) string {
|
|
|
|
if len(extra)+len(message) <= sizeLimit {
|
|
|
|
return message + extra
|
|
|
|
}
|
2018-08-28 15:26:47 -05:00
|
|
|
log.Debug("Line too long for image caption. value: %s", extra)
|
2018-03-05 09:26:35 -06:00
|
|
|
return message
|
|
|
|
}
|
|
|
|
|
2017-11-22 09:41:36 -06:00
|
|
|
func (this *TelegramNotifier) Notify(evalContext *alerting.EvalContext) error {
|
|
|
|
var cmd *m.SendWebhookSync
|
Simplify comparison to bool constant (gosimple)
This fixes:
build.go:553:6: should omit comparison to bool constant, can be simplified to !strings.Contains(path, ".sha256") (S1002)
pkg/cmd/grafana-cli/commands/ls_command.go:27:5: should omit comparison to bool constant, can be simplified to !pluginDirInfo.IsDir() (S1002)
pkg/components/dynmap/dynmap_test.go:24:5: should omit comparison to bool constant, can be simplified to !value (S1002)
pkg/components/dynmap/dynmap_test.go:122:14: should omit comparison to bool constant, can be simplified to b (S1002)
pkg/components/dynmap/dynmap_test.go:125:14: should omit comparison to bool constant, can be simplified to !b (S1002)
pkg/components/dynmap/dynmap_test.go:128:14: should omit comparison to bool constant, can be simplified to !b (S1002)
pkg/models/org_user.go:51:5: should omit comparison to bool constant, can be simplified to !(*r).IsValid() (S1002)
pkg/plugins/datasource/wrapper/datasource_plugin_wrapper_test.go:77:12: should omit comparison to bool constant, can be simplified to !haveBool (S1002)
pkg/services/alerting/conditions/evaluator.go:23:9: should omit comparison to bool constant, can be simplified to !reducedValue.Valid (S1002)
pkg/services/alerting/conditions/evaluator.go:48:5: should omit comparison to bool constant, can be simplified to !reducedValue.Valid (S1002)
pkg/services/alerting/conditions/evaluator.go:91:5: should omit comparison to bool constant, can be simplified to !reducedValue.Valid (S1002)
pkg/services/alerting/conditions/query.go:56:6: should omit comparison to bool constant, can be simplified to !reducedValue.Valid (S1002)
pkg/services/alerting/extractor.go:107:20: should omit comparison to bool constant, can be simplified to !enabled.MustBool() (S1002)
pkg/services/alerting/notifiers/telegram.go:222:41: should omit comparison to bool constant, can be simplified to this.UploadImage (S1002)
pkg/services/sqlstore/apikey.go:58:12: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/apikey.go:72:12: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/dashboard.go:66:33: should omit comparison to bool constant, can be simplified to !cmd.Overwrite (S1002)
pkg/services/sqlstore/dashboard.go:175:12: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/dashboard.go:311:13: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/dashboard.go:444:12: should omit comparison to bool constant, can be simplified to !exists (S1002)
pkg/services/sqlstore/dashboard.go:472:12: should omit comparison to bool constant, can be simplified to !exists (S1002)
pkg/services/sqlstore/dashboard.go:554:32: should omit comparison to bool constant, can be simplified to !cmd.Overwrite (S1002)
pkg/services/sqlstore/dashboard_snapshot.go:83:12: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/plugin_setting.go:39:12: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/quota.go:34:12: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/quota.go:111:6: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/quota.go:136:12: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/quota.go:213:6: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/temp_user.go:129:12: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/user.go:157:12: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/user.go:182:5: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/user.go:191:12: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/user.go:212:12: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/services/sqlstore/user.go:307:12: should omit comparison to bool constant, can be simplified to !has (S1002)
pkg/social/generic_oauth.go:185:5: should omit comparison to bool constant, can be simplified to !s.extractToken(&data, token) (S1002)
pkg/tsdb/mssql/mssql.go:148:39: should omit comparison to bool constant, can be simplified to ok (S1002)
pkg/tsdb/mssql/mssql.go:212:6: should omit comparison to bool constant, can be simplified to !query.Model.Get("fillNull").MustBool(false) (S1002)
pkg/tsdb/mssql/mssql.go:247:56: should omit comparison to bool constant, can be simplified to ok (S1002)
pkg/tsdb/mssql/mssql.go:274:7: should omit comparison to bool constant, can be simplified to !exist (S1002)
pkg/tsdb/mssql/mssql.go:282:8: should omit comparison to bool constant, can be simplified to !exist (S1002)
pkg/tsdb/mysql/mysql.go:221:6: should omit comparison to bool constant, can be simplified to !query.Model.Get("fillNull").MustBool(false) (S1002)
pkg/tsdb/mysql/mysql.go:256:56: should omit comparison to bool constant, can be simplified to ok (S1002)
pkg/tsdb/mysql/mysql.go:283:7: should omit comparison to bool constant, can be simplified to !exist (S1002)
pkg/tsdb/mysql/mysql.go:291:8: should omit comparison to bool constant, can be simplified to !exist (S1002)
pkg/tsdb/postgres/postgres.go:134:39: should omit comparison to bool constant, can be simplified to ok (S1002)
pkg/tsdb/postgres/postgres.go:201:6: should omit comparison to bool constant, can be simplified to !query.Model.Get("fillNull").MustBool(false) (S1002)
pkg/tsdb/postgres/postgres.go:236:56: should omit comparison to bool constant, can be simplified to ok (S1002)
pkg/tsdb/postgres/postgres.go:263:7: should omit comparison to bool constant, can be simplified to !exist (S1002)
pkg/tsdb/postgres/postgres.go:271:8: should omit comparison to bool constant, can be simplified to !exist (S1002)
2018-04-16 13:12:59 -05:00
|
|
|
if evalContext.ImagePublicUrl == "" && this.UploadImage {
|
2017-11-22 09:41:36 -06:00
|
|
|
cmd = this.buildMessage(evalContext, true)
|
|
|
|
} else {
|
|
|
|
cmd = this.buildMessage(evalContext, false)
|
|
|
|
}
|
2016-12-30 06:57:12 -06:00
|
|
|
|
|
|
|
if err := bus.DispatchCtx(evalContext.Ctx, cmd); err != nil {
|
|
|
|
this.log.Error("Failed to send webhook", "error", err, "webhook", this.Name)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|