mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 21:19:28 -06:00
a8b4a4bb45
* update to alerting 20230418161049-5f374e58cb32 * rename renamed structs in https://github.com/grafana/alerting/pull/73 * update ValidateContactPoint to use BuildReceiverConfiguration * update logger factory according to changes * rewrite integration builder Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package notifier
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/alerting/receivers"
|
|
|
|
"github.com/grafana/grafana/pkg/services/notifications"
|
|
)
|
|
|
|
type sender struct {
|
|
ns notifications.Service
|
|
}
|
|
|
|
func (s sender) SendWebhook(ctx context.Context, cmd *receivers.SendWebhookSettings) error {
|
|
return s.ns.SendWebhookSync(ctx, ¬ifications.SendWebhookSync{
|
|
Url: cmd.URL,
|
|
User: cmd.User,
|
|
Password: cmd.Password,
|
|
Body: cmd.Body,
|
|
HttpMethod: cmd.HTTPMethod,
|
|
HttpHeader: cmd.HTTPHeader,
|
|
ContentType: cmd.ContentType,
|
|
Validation: cmd.Validation,
|
|
})
|
|
}
|
|
|
|
func (s sender) SendEmail(ctx context.Context, cmd *receivers.SendEmailSettings) error {
|
|
var attached []*notifications.SendEmailAttachFile
|
|
if cmd.AttachedFiles != nil {
|
|
attached = make([]*notifications.SendEmailAttachFile, 0, len(cmd.AttachedFiles))
|
|
for _, file := range cmd.AttachedFiles {
|
|
attached = append(attached, ¬ifications.SendEmailAttachFile{
|
|
Name: file.Name,
|
|
Content: file.Content,
|
|
})
|
|
}
|
|
}
|
|
return s.ns.SendEmailCommandHandlerSync(ctx, ¬ifications.SendEmailCommandSync{
|
|
SendEmailCommand: notifications.SendEmailCommand{
|
|
To: cmd.To,
|
|
SingleEmail: cmd.SingleEmail,
|
|
Template: cmd.Template,
|
|
Subject: cmd.Subject,
|
|
Data: cmd.Data,
|
|
Info: cmd.Info,
|
|
ReplyTo: cmd.ReplyTo,
|
|
EmbeddedFiles: cmd.EmbeddedFiles,
|
|
AttachedFiles: attached,
|
|
},
|
|
})
|
|
}
|