fleet/server/mail/invite.go
Zachary Wasserman 45f6a74740
Allow import of github.com/kolide/fleet (#2213)
Previously a Go package attempting to import Fleet packages would run
into an error like "server/kolide/emails.go:93:23: undefined: Asset".

This commit refactors bindata asset handling to allow importing Fleet as
a library without changing the typical developer experience.
2020-03-29 19:22:04 -07:00

30 lines
598 B
Go

package mail
import (
"bytes"
"html/template"
"github.com/kolide/fleet/server/kolide"
)
// InviteMailer is used to build an email template for the invite email.
type InviteMailer struct {
*kolide.Invite
BaseURL template.URL
AssetURL template.URL
InvitedByUsername string
OrgName string
}
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
}