@@ -36,17 +36,6 @@ import (
3636// https://api.slack.com/reference/messaging/attachments#legacy_fields - 1024, no units given, assuming runes or characters.
3737const maxTitleLenRunes = 1024
3838
39- // Notifier implements a Notifier for Slack notifications.
40- type Notifier struct {
41- conf * config.SlackConfig
42- tmpl * template.Template
43- logger * slog.Logger
44- client * http.Client
45- retrier * notify.Retrier
46-
47- postJSONFunc func (ctx context.Context , client * http.Client , url string , body io.Reader ) (* http.Response , error )
48- }
49-
5039// New returns a new Slack notification handler.
5140func New (c * config.SlackConfig , t * template.Template , l * slog.Logger , httpOpts ... commoncfg.HTTPClientOption ) (* Notifier , error ) {
5241 client , err := notify .NewClientWithTracing (* c .HTTPConfig , "slack" , httpOpts ... )
@@ -64,43 +53,6 @@ func New(c *config.SlackConfig, t *template.Template, l *slog.Logger, httpOpts .
6453 }, nil
6554}
6655
67- // request is the request for sending a slack notification.
68- type request struct {
69- Channel string `json:"channel,omitempty"`
70- Timestamp string `json:"ts,omitempty"`
71- Username string `json:"username,omitempty"`
72- IconEmoji string `json:"icon_emoji,omitempty"`
73- IconURL string `json:"icon_url,omitempty"`
74- LinkNames bool `json:"link_names,omitempty"`
75- Text string `json:"text,omitempty"`
76- Attachments []attachment `json:"attachments"`
77- }
78-
79- // attachment is used to display a richly-formatted message block.
80- type attachment struct {
81- Title string `json:"title,omitempty"`
82- TitleLink string `json:"title_link,omitempty"`
83- Pretext string `json:"pretext,omitempty"`
84- Text string `json:"text"`
85- Fallback string `json:"fallback"`
86- CallbackID string `json:"callback_id"`
87- Fields []config.SlackField `json:"fields,omitempty"`
88- Actions []config.SlackAction `json:"actions,omitempty"`
89- ImageURL string `json:"image_url,omitempty"`
90- ThumbURL string `json:"thumb_url,omitempty"`
91- Footer string `json:"footer"`
92- Color string `json:"color,omitempty"`
93- MrkdwnIn []string `json:"mrkdwn_in,omitempty"`
94- }
95-
96- // slackResponse represents the response from Slack API.
97- type slackResponse struct {
98- OK bool `json:"ok"`
99- Error string `json:"error,omitempty"`
100- Channel string `json:"channel,omitempty"`
101- Timestamp string `json:"ts,omitempty"`
102- }
103-
10456// Notify implements the Notifier interface.
10557func (n * Notifier ) Notify (ctx context.Context , as ... * types.Alert ) (bool , error ) {
10658 var err error
0 commit comments