33 lines
584 B
Go
Raw Normal View History

2024-05-27 14:51:22 +02:00
package slack
2024-05-27 11:44:24 +02:00
import (
"bytes"
"encoding/json"
"log"
"net/http"
"os"
2024-05-27 14:16:50 +02:00
"wazuh-notify/services"
2024-05-27 11:44:24 +02:00
"wazuh-notify/types"
)
func SendSlack(params types.Params) {
2024-05-27 14:51:22 +02:00
message := SlackMessage{
2024-05-27 14:16:50 +02:00
Text: services.BuildMessage(params, "slack", params.MarkdownEmphasis.Slack) +
2024-05-27 13:48:08 +02:00
"*Tags:* " + params.Tags + "\n\n" +
2024-05-27 14:16:50 +02:00
params.General.Click,
2024-05-27 13:48:08 +02:00
}
2024-05-27 11:44:24 +02:00
payload := new(bytes.Buffer)
err := json.NewEncoder(payload).Encode(message)
if err != nil {
return
}
_, err = http.Post(os.Getenv("SLACK_URL"), "application/json", payload)
if err != nil {
log.Fatalf("An Error Occured %v", err)
}
}