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