Alerting: Upgrade grafana/alerting to use EmbeddedContents (#99983)

* Upgrade grafana/alerting to include EmbeddedContents for email images
This commit is contained in:
Matthew Jacobson
2025-02-06 11:29:43 -05:00
committed by GitHub
parent 011301f06f
commit ccb0e9222a
9 changed files with 50 additions and 27 deletions
+19 -9
View File
@@ -222,16 +222,26 @@ func (e emailSender) SendWebhook(ctx context.Context, cmd *receivers.SendWebhook
}
func (e 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 e.ns.SendEmailCommandHandlerSync(ctx, &notifications.SendEmailCommandSync{
SendEmailCommand: notifications.SendEmailCommand{
To: cmd.To,
SingleEmail: cmd.SingleEmail,
Template: cmd.Template,
Subject: cmd.Subject,
Data: cmd.Data,
ReplyTo: cmd.ReplyTo,
EmbeddedFiles: cmd.EmbeddedFiles,
},
SendEmailCommand: sendEmailCommand,
})
}
+19 -9
View File
@@ -27,15 +27,25 @@ func (s sender) SendWebhook(ctx context.Context, cmd *receivers.SendWebhookSetti
}
func (s sender) 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, &notifications.SendEmailCommandSync{
SendEmailCommand: notifications.SendEmailCommand{
To: cmd.To,
SingleEmail: cmd.SingleEmail,
Template: cmd.Template,
Subject: cmd.Subject,
Data: cmd.Data,
ReplyTo: cmd.ReplyTo,
EmbeddedFiles: cmd.EmbeddedFiles,
},
SendEmailCommand: sendEmailCommand,
})
}