mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
parent
597ebb1161
commit
c467e48940
@ -7,6 +7,7 @@ var ErrInvalidEmailCode = errors.New("Invalid or expired email code")
|
||||
type SendEmailCommand struct {
|
||||
To []string
|
||||
Template string
|
||||
Subject string
|
||||
Data map[string]interface{}
|
||||
Info string
|
||||
EmbededFiles []string
|
||||
|
@ -57,6 +57,7 @@ func (this *EmailNotifier) Notify(evalContext *alerting.EvalContext) error {
|
||||
|
||||
cmd := &m.SendEmailCommandSync{
|
||||
SendEmailCommand: m.SendEmailCommand{
|
||||
Subject: evalContext.GetNotificationTitle(),
|
||||
Data: map[string]interface{}{
|
||||
"Title": evalContext.GetNotificationTitle(),
|
||||
"State": evalContext.Rule.State,
|
||||
|
@ -111,7 +111,6 @@ func buildEmailMessage(cmd *m.SendEmailCommand) (*Message, error) {
|
||||
|
||||
var buffer bytes.Buffer
|
||||
var err error
|
||||
var subjectText interface{}
|
||||
|
||||
data := cmd.Data
|
||||
if data == nil {
|
||||
@ -124,6 +123,9 @@ func buildEmailMessage(cmd *m.SendEmailCommand) (*Message, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
subject := cmd.Subject
|
||||
if cmd.Subject == "" {
|
||||
var subjectText interface{}
|
||||
subjectData := data["Subject"].(map[string]interface{})
|
||||
subjectText, hasSubject := subjectData["value"]
|
||||
|
||||
@ -142,10 +144,13 @@ func buildEmailMessage(cmd *m.SendEmailCommand) (*Message, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
subject = subjectBuffer.String()
|
||||
}
|
||||
|
||||
return &Message{
|
||||
To: cmd.To,
|
||||
From: setting.Smtp.FromAddress,
|
||||
Subject: subjectBuffer.String(),
|
||||
Subject: subject,
|
||||
Body: buffer.String(),
|
||||
EmbededFiles: cmd.EmbededFiles,
|
||||
}, nil
|
||||
|
@ -80,6 +80,7 @@ func sendEmailCommandHandlerSync(ctx context.Context, cmd *m.SendEmailCommandSyn
|
||||
Template: cmd.Template,
|
||||
To: cmd.To,
|
||||
EmbededFiles: cmd.EmbededFiles,
|
||||
Subject: cmd.Subject,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user