浏览代码

(feat) Add image to LINE notify (#8771)

0x6875790d0a 8 年之前
父节点
当前提交
a622c55b1b
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      pkg/services/alerting/notifiers/line.go

+ 6 - 1
pkg/services/alerting/notifiers/line.go

@@ -75,12 +75,17 @@ func (this *LineNotifier) createAlert(evalContext *alerting.EvalContext) error {
 	body := fmt.Sprintf("%s - %s\n%s", evalContext.Rule.Name, ruleUrl, evalContext.Rule.Message)
 	form.Add("message", body)
 
+	if evalContext.ImagePublicUrl != "" {
+		form.Add("imageThumbnail", evalContext.ImagePublicUrl)
+		form.Add("imageFullsize", evalContext.ImagePublicUrl)
+	}
+
 	cmd := &m.SendWebhookSync{
 		Url:        lineNotifyUrl,
 		HttpMethod: "POST",
 		HttpHeader: map[string]string{
 			"Authorization": fmt.Sprintf("Bearer %s", this.Token),
-			"Content-Type":  "application/x-www-form-urlencoded",
+			"Content-Type":  "application/x-www-form-urlencoded;charset=UTF-8",
 		},
 		Body: form.Encode(),
 	}