2020-03-30 02:22:04 +00:00
|
|
|
package mail
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"html/template"
|
|
|
|
|
2021-06-26 04:46:51 +00:00
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
2020-03-30 02:22:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// InviteMailer is used to build an email template for the invite email.
|
|
|
|
type InviteMailer struct {
|
2021-06-06 22:07:29 +00:00
|
|
|
*fleet.Invite
|
2021-06-24 20:42:29 +00:00
|
|
|
BaseURL template.URL
|
|
|
|
AssetURL template.URL
|
|
|
|
InvitedBy string
|
|
|
|
OrgName string
|
2020-03-30 02:22:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (i *InviteMailer) Message() ([]byte, error) {
|
|
|
|
t, err := getTemplate("server/mail/templates/invite_token.html")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
var msg bytes.Buffer
|
|
|
|
if err = t.Execute(&msg, i); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return msg.Bytes(), nil
|
|
|
|
}
|