2024-05-27 14:51:22 +02:00
|
|
|
package ntfy
|
2024-05-08 01:56:48 +02:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"net/http"
|
|
|
|
|
"os"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
2024-05-27 14:16:50 +02:00
|
|
|
"wazuh-notify/services"
|
2024-05-08 01:56:48 +02:00
|
|
|
"wazuh-notify/types"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func SendNtfy(params types.Params) {
|
|
|
|
|
|
2024-05-27 14:16:50 +02:00
|
|
|
req, _ := http.NewRequest(
|
|
|
|
|
"POST",
|
|
|
|
|
os.Getenv("NTFY_URL"),
|
2024-05-27 14:47:18 +02:00
|
|
|
strings.NewReader(" "+services.BuildMessage(params, "ntfy", params.MarkdownEmphasis.Ntfy)))
|
2024-05-27 11:36:33 +02:00
|
|
|
|
2024-05-27 13:59:28 +02:00
|
|
|
req.Header.Set("Content-Type", "text/markdown")
|
2024-05-08 01:56:48 +02:00
|
|
|
|
2024-05-27 13:01:39 +02:00
|
|
|
if params.General.Sender != "" {
|
|
|
|
|
req.Header.Add("Title", params.General.Sender)
|
2024-05-08 01:56:48 +02:00
|
|
|
}
|
|
|
|
|
if params.Tags != "" {
|
|
|
|
|
req.Header.Add("Tags", params.Tags)
|
|
|
|
|
}
|
2024-05-27 13:01:39 +02:00
|
|
|
if params.General.Click != "" {
|
|
|
|
|
req.Header.Add("Click", params.General.Click)
|
2024-05-08 01:56:48 +02:00
|
|
|
}
|
|
|
|
|
if params.Priority != 0 {
|
|
|
|
|
req.Header.Add("Priority", strconv.Itoa(params.Priority))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
http.DefaultClient.Do(req)
|
|
|
|
|
}
|