|
|
@ -88,13 +88,13 @@ func (n *Notify) Send() error {
|
|
|
|
notifyScripts := []string{}
|
|
|
|
notifyScripts := []string{}
|
|
|
|
notifyShoutrrr := []string{}
|
|
|
|
notifyShoutrrr := []string{}
|
|
|
|
|
|
|
|
|
|
|
|
for _, url := range configUrls {
|
|
|
|
for ndx, _ := range configUrls {
|
|
|
|
if strings.HasPrefix(url, "https://") || strings.HasPrefix(url, "http://") {
|
|
|
|
if strings.HasPrefix(configUrls[ndx], "https://") || strings.HasPrefix(configUrls[ndx], "http://") {
|
|
|
|
notifyWebhooks = append(notifyWebhooks, url)
|
|
|
|
notifyWebhooks = append(notifyWebhooks, configUrls[ndx])
|
|
|
|
} else if strings.HasPrefix(url, "script://") {
|
|
|
|
} else if strings.HasPrefix(configUrls[ndx], "script://") {
|
|
|
|
notifyScripts = append(notifyScripts, url)
|
|
|
|
notifyScripts = append(notifyScripts, configUrls[ndx])
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
notifyShoutrrr = append(notifyShoutrrr, url)
|
|
|
|
notifyShoutrrr = append(notifyShoutrrr, configUrls[ndx])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -106,16 +106,20 @@ func (n *Notify) Send() error {
|
|
|
|
//var wg sync.WaitGroup
|
|
|
|
//var wg sync.WaitGroup
|
|
|
|
var eg errgroup.Group
|
|
|
|
var eg errgroup.Group
|
|
|
|
|
|
|
|
|
|
|
|
for _, notifyWebhook := range notifyWebhooks {
|
|
|
|
for _, url := range notifyWebhooks {
|
|
|
|
// execute collection in parallel go-routines
|
|
|
|
// execute collection in parallel go-routines
|
|
|
|
eg.Go(func() error { return n.SendWebhookNotification(notifyWebhook) })
|
|
|
|
_url := url
|
|
|
|
|
|
|
|
eg.Go(func() error { return n.SendWebhookNotification(_url) })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, notifyScript := range notifyScripts {
|
|
|
|
for _, url := range notifyScripts {
|
|
|
|
// execute collection in parallel go-routines
|
|
|
|
// execute collection in parallel go-routines
|
|
|
|
eg.Go(func() error { return n.SendScriptNotification(notifyScript) })
|
|
|
|
_url := url
|
|
|
|
|
|
|
|
eg.Go(func() error { return n.SendScriptNotification(_url) })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, shoutrrrUrl := range notifyShoutrrr {
|
|
|
|
for _, url := range notifyShoutrrr {
|
|
|
|
eg.Go(func() error { return n.SendShoutrrrNotification(shoutrrrUrl) })
|
|
|
|
// execute collection in parallel go-routines
|
|
|
|
|
|
|
|
_url := url
|
|
|
|
|
|
|
|
eg.Go(func() error { return n.SendShoutrrrNotification(_url) })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//and wait for completion, error or timeout.
|
|
|
|
//and wait for completion, error or timeout.
|
|
|
@ -193,7 +197,7 @@ func (n *Notify) SendShoutrrrNotification(shoutrrrUrl string) error {
|
|
|
|
|
|
|
|
|
|
|
|
//sender.SetLogger(n.Logger.)
|
|
|
|
//sender.SetLogger(n.Logger.)
|
|
|
|
serviceName, params, err := n.GenShoutrrrNotificationParams(shoutrrrUrl)
|
|
|
|
serviceName, params, err := n.GenShoutrrrNotificationParams(shoutrrrUrl)
|
|
|
|
n.Logger.Debug("notification data for %s: (%s)\n%v", serviceName, shoutrrrUrl, params)
|
|
|
|
n.Logger.Debugf("notification data for %s: (%s)\n%v", serviceName, shoutrrrUrl, params)
|
|
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
n.Logger.Errorf("An error occurred occurred while generating notification payload for %s:\n %v", serviceName, shoutrrrUrl, err)
|
|
|
|
n.Logger.Errorf("An error occurred occurred while generating notification payload for %s:\n %v", serviceName, shoutrrrUrl, err)
|
|
|
@ -235,17 +239,19 @@ func (n *Notify) GenShoutrrrNotificationParams(shoutrrrUrl string) (string, *sho
|
|
|
|
subject := n.Payload.Subject
|
|
|
|
subject := n.Payload.Subject
|
|
|
|
switch serviceName {
|
|
|
|
switch serviceName {
|
|
|
|
// no params supported for these services
|
|
|
|
// no params supported for these services
|
|
|
|
case "discord", "hangouts", "ifttt", "mattermost", "teams":
|
|
|
|
case "discord", "hangouts", "ifttt", "mattermost", "teams", "rocketchat":
|
|
|
|
break
|
|
|
|
break
|
|
|
|
case "gotify":
|
|
|
|
case "gotify":
|
|
|
|
(*params)["title"] = subject
|
|
|
|
(*params)["title"] = subject
|
|
|
|
case "join":
|
|
|
|
case "join":
|
|
|
|
(*params)["title"] = subject
|
|
|
|
(*params)["title"] = subject
|
|
|
|
(*params)["icon"] = logoUrl
|
|
|
|
(*params)["icon"] = logoUrl
|
|
|
|
|
|
|
|
case "opsgenie":
|
|
|
|
|
|
|
|
(*params)["description"] = subject
|
|
|
|
case "pushbullet":
|
|
|
|
case "pushbullet":
|
|
|
|
(*params)["title"] = subject
|
|
|
|
(*params)["title"] = subject
|
|
|
|
case "pushover":
|
|
|
|
case "pushover":
|
|
|
|
(*params)["subject"] = subject
|
|
|
|
(*params)["title"] = subject
|
|
|
|
case "slack":
|
|
|
|
case "slack":
|
|
|
|
(*params)["title"] = subject
|
|
|
|
(*params)["title"] = subject
|
|
|
|
(*params)["thumb_url"] = logoUrl
|
|
|
|
(*params)["thumb_url"] = logoUrl
|
|
|
|