2015-06-04 17:23:46 +02:00
|
|
|
package notifications
|
|
|
|
|
|
|
|
|
|
import (
|
2020-02-29 13:35:15 +01:00
|
|
|
"github.com/grafana/grafana/pkg/models"
|
2015-06-04 17:23:46 +02:00
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
|
|
|
)
|
|
|
|
|
|
2020-04-29 21:37:21 +02:00
|
|
|
// AttachedFile struct represents email attached files.
|
2019-08-26 16:44:18 +02:00
|
|
|
type AttachedFile struct {
|
|
|
|
|
Name string
|
|
|
|
|
Content []byte
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-29 21:37:21 +02:00
|
|
|
// Message is representation of the email message.
|
2015-06-08 16:51:25 +02:00
|
|
|
type Message struct {
|
2019-08-26 16:44:18 +02:00
|
|
|
To []string
|
2020-01-10 16:06:33 +01:00
|
|
|
SingleEmail bool
|
2019-08-26 16:44:18 +02:00
|
|
|
From string
|
|
|
|
|
Subject string
|
2021-07-19 12:31:51 +02:00
|
|
|
Body map[string]string
|
2019-08-26 16:44:18 +02:00
|
|
|
Info string
|
|
|
|
|
ReplyTo []string
|
2020-06-01 17:11:25 +02:00
|
|
|
EmbeddedFiles []string
|
2019-08-26 16:44:18 +02:00
|
|
|
AttachedFiles []*AttachedFile
|
2015-06-04 17:23:46 +02:00
|
|
|
}
|
|
|
|
|
|
2020-02-29 13:35:15 +01:00
|
|
|
func setDefaultTemplateData(data map[string]interface{}, u *models.User) {
|
2015-06-04 17:23:46 +02:00
|
|
|
data["AppUrl"] = setting.AppUrl
|
|
|
|
|
data["BuildVersion"] = setting.BuildVersion
|
|
|
|
|
data["BuildStamp"] = setting.BuildStamp
|
2015-06-08 10:57:01 +02:00
|
|
|
data["EmailCodeValidHours"] = setting.EmailCodeValidMinutes / 60
|
2015-06-05 11:08:19 +02:00
|
|
|
data["Subject"] = map[string]interface{}{}
|
2015-06-04 17:23:46 +02:00
|
|
|
if u != nil {
|
2015-06-08 10:57:01 +02:00
|
|
|
data["Name"] = u.NameOrFallback()
|
2015-06-04 17:23:46 +02:00
|
|
|
}
|
|
|
|
|
}
|