Files
grafana/pkg/services/notifications/email.go
T
Marcus Efraimsson 0f0772b629 Alerting: Adds support for sending a single email to all recipients in notification channel (#21091)
When an alert is sent by e-mail, the process sends an e-mail to 
each recipient separately. This PR is a single delivery to all recipients.
For companies that use e-mail extensively, this is necessary in order 
not to overload the sending queue.

Replaces #18013
Fixes #12650

Co-authored-by: Henrique Oliveira <holiiveira@users.noreply.github.com>
2020-01-10 16:06:33 +01:00

37 lines
885 B
Go

package notifications
import (
m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
)
// AttachedFile is struct representating email attached files
type AttachedFile struct {
Name string
Content []byte
}
// Message is representation of the email message
type Message struct {
To []string
SingleEmail bool
From string
Subject string
Body string
Info string
ReplyTo []string
EmbededFiles []string
AttachedFiles []*AttachedFile
}
func setDefaultTemplateData(data map[string]interface{}, u *m.User) {
data["AppUrl"] = setting.AppUrl
data["BuildVersion"] = setting.BuildVersion
data["BuildStamp"] = setting.BuildStamp
data["EmailCodeValidHours"] = setting.EmailCodeValidMinutes / 60
data["Subject"] = map[string]interface{}{}
if u != nil {
data["Name"] = u.NameOrFallback()
}
}