Skip to content

Commit

Permalink
Dingtalk notify optimization: complete docs & add escape (megaease#191)
Browse files Browse the repository at this point in the history
* docs: add dingtalk notify secret

* fix: escape to prevent possible parse failure
  • Loading branch information
samanhappy committed Aug 10, 2022
1 parent 504c529 commit 62ea263
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ notify:
dingtalk:
- name: "dingtalk alert service"
webhook: "https://oapi.dingtalk.com/robot/send?access_token=xxxx"
secret: "" # sign secret if set
lark:
- name: "lark alert service"
webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/d5366199-xxxx-xxxx-bd81-a57d1dd95de4"
Expand Down
2 changes: 1 addition & 1 deletion notify/dingtalk/dingtalk.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c *NotifyConfig) SendDingtalkNotification(title, msg string) error {
"text": "%s"
}
}
`, title, msg)
`, report.JSONEscape(title), report.JSONEscape(msg))
req, err := http.NewRequest(http.MethodPost, addSign(c.WebhookURL, c.SignSecret), bytes.NewBuffer([]byte(msgContent)))
if err != nil {
return err
Expand Down

0 comments on commit 62ea263

Please sign in to comment.