add mm notification with notify plugin
This commit is contained in:
parent
5e931ebe8e
commit
26a3d2dafa
|
@ -17,7 +17,6 @@ type mm struct {
|
|||
Channel string `json:"channel"`
|
||||
Username string `json:"username"`
|
||||
Text string `json:"text"`
|
||||
Props string `json:"props"`
|
||||
}
|
||||
|
||||
func SendMM(message MatterMostMessage) {
|
||||
|
|
|
@ -125,6 +125,7 @@ func handleNotice(notice Notice, bs []byte) {
|
|||
wecomset := make(map[string]struct{})
|
||||
dingtalkset := make(map[string]struct{})
|
||||
feishuset := make(map[string]struct{})
|
||||
mmset := make(map[string]struct{})
|
||||
|
||||
for _, user := range notice.Event.NotifyUsersObj {
|
||||
if user.Email != "" {
|
||||
|
@ -155,6 +156,11 @@ func handleNotice(notice Notice, bs []byte) {
|
|||
if ret.Exists() {
|
||||
feishuset[ret.String()] = struct{}{}
|
||||
}
|
||||
|
||||
ret = gjson.GetBytes(bs, "mm_webhook_url")
|
||||
if ret.Exists() {
|
||||
mmset[ret.String()] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
phones := StringSetKeys(phoneset)
|
||||
|
@ -236,6 +242,23 @@ func handleNotice(notice Notice, bs []byte) {
|
|||
AtMobiles: phones,
|
||||
Tokens: StringSetKeys(feishuset),
|
||||
})
|
||||
case "mm":
|
||||
if len(mmset) == 0 {
|
||||
continue
|
||||
}
|
||||
if !slice.ContainsString(config.C.Alerting.NotifyBuiltinChannels, "mm") {
|
||||
continue
|
||||
}
|
||||
|
||||
content, has := notice.Tpls["mm.tpl"]
|
||||
if !has {
|
||||
content = "mm.tpl not found"
|
||||
}
|
||||
|
||||
sender.SendMM(sender.MatterMostMessage{
|
||||
Text: content,
|
||||
Tokens: StringSetKeys(mmset),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue