mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 09:34:27 +08:00

* Update grafana alerting from de176b4a0309 to 83b6de6b0a35 Includes: - https://github.com/grafana/alerting/pull/319 - https://github.com/grafana/alerting/pull/317 * Remove unused SendWebhook method from sender struct grafana/alerting hasn't used the grafana webhook sender for a while now, so this method is no longer used anywhere. - Removed SendWebhook from the sender struct and rename it to emailSender so that its use is clearer. - Also, for similar reasons, the Webhook method on Grafana's webhook sender `sendWebRequestSync` should not call grafana/alerting code for NewTLSClient. The previous grafana/alerting function is vendored into grafana. * Use BuildReceiverIntegrations new func signature
38 lines
1001 B
Go
38 lines
1001 B
Go
package notifier
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/alerting/receivers"
|
|
|
|
"github.com/grafana/grafana/pkg/services/notifications"
|
|
)
|
|
|
|
type emailSender struct {
|
|
ns notifications.Service
|
|
}
|
|
|
|
func (s emailSender) SendEmail(ctx context.Context, cmd *receivers.SendEmailSettings) error {
|
|
sendEmailCommand := notifications.SendEmailCommand{
|
|
To: cmd.To,
|
|
SingleEmail: cmd.SingleEmail,
|
|
Template: cmd.Template,
|
|
Subject: cmd.Subject,
|
|
Data: cmd.Data,
|
|
ReplyTo: cmd.ReplyTo,
|
|
EmbeddedFiles: cmd.EmbeddedFiles,
|
|
}
|
|
if len(cmd.EmbeddedContents) > 0 {
|
|
sendEmailCommand.EmbeddedContents = make([]notifications.EmbeddedContent, len(cmd.EmbeddedContents))
|
|
for i, ec := range cmd.EmbeddedContents {
|
|
sendEmailCommand.EmbeddedContents[i] = notifications.EmbeddedContent{
|
|
Name: ec.Name,
|
|
Content: ec.Content,
|
|
}
|
|
}
|
|
}
|
|
return s.ns.SendEmailCommandHandlerSync(ctx, ¬ifications.SendEmailCommandSync{
|
|
SendEmailCommand: sendEmailCommand,
|
|
})
|
|
}
|