Documentation ¶
Index ¶
- Constants
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDigest(name string) ([sha256.Size]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func AssetString(name string) (string, error)
- func AttachJSON(message *mail.SGMailV3, data []byte, filename string) (err error)
- func DeliverCertsEmail(sender, senderEmail, recipient, recipientEmail, attachmentPath string, ...) (message *mail.SGMailV3, err error)
- func Digests() (map[string][sha256.Size]byte, error)
- func GetRecipient(msg *sgmail.SGMailV3) (recipient string, err error)
- func LoadAttachment(message *mail.SGMailV3, attachmentPath string) (err error)
- func MustAsset(name string) []byte
- func MustAssetString(name string) string
- func PurgeMockEmails()
- func RejectRegistrationEmail(sender, senderEmail, recipient, recipientEmail string, ...) (message *mail.SGMailV3, err error)
- func Render(name string, data interface{}) (text, html string, err error)
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func ReviewRequestEmail(sender, senderEmail, recipient, recipientEmail string, data ReviewRequestData) (message *mail.SGMailV3, err error)
- func VerifyContactEmail(sender, senderEmail, recipient, recipientEmail string, data VerifyContactData) (message *mail.SGMailV3, err error)
- func WriteMIME(msg *sgmail.SGMailV3, path string) (err error)
- type DeliverCertsData
- type EmailClient
- type EmailManager
- func (m *EmailManager) Send(message *sgmail.SGMailV3) (err error)
- func (m *EmailManager) SendDeliverCertificates(vasp *pb.VASP, path string) (sent int, err error)
- func (m *EmailManager) SendRejectRegistration(vasp *pb.VASP, reason string) (sent int, err error)
- func (m *EmailManager) SendReviewRequest(vasp *pb.VASP) (sent int, err error)
- func (m *EmailManager) SendVerifyContact(vasp *pb.VASP, contact *pb.Contact) (err error)
- func (m *EmailManager) SendVerifyContacts(vasp *pb.VASP) (sent int, err error)
- type RejectRegistrationData
- type ReviewRequestData
- type VerifyContactData
Constants ¶
const ( VerifyContactRE = "TRISA: Please verify your email address" ReviewRequestRE = "New TRISA Global Directory Registration Request" RejectRegistrationRE = "TRISA Global Directory Registration Update" DeliverCertsRE = "Welcome to the TRISA network!" )
Subjects for creating emails on demand.
const AssetDebug = false
AssetDebug is true if the assets were built with the debug flag enabled.
Variables ¶
var MockEmails [][]byte
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDigest ¶
AssetDigest returns the digest of the file with the given name. It returns an error if the asset could not be found or the digest could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"}, AssetDir("data/img") would return []string{"a.png", "b.png"}, AssetDir("foo.txt") and AssetDir("notexist") would return an error, and AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetString ¶
AssetString returns the asset contents as a string (instead of a []byte).
func AttachJSON ¶
AttachJSON by marshaling the specified data into human-readable data and encode and attach it to the email as a file.
func DeliverCertsEmail ¶
func DeliverCertsEmail(sender, senderEmail, recipient, recipientEmail, attachmentPath string, data DeliverCertsData) (message *mail.SGMailV3, err error)
DeliverCertsEmail creates a new deliver certs email, ready for sending by rendering the text and html templates with the supplied data, loading the attachment from disk then constructing a sendgrid email.
func LoadAttachment ¶
LoadAttachment onto email from a file on disk.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func MustAssetString ¶
MustAssetString is like AssetString but panics when Asset would return an error. It simplifies safe initialization of global variables.
func PurgeMockEmails ¶
func PurgeMockEmails()
func RejectRegistrationEmail ¶
func RejectRegistrationEmail(sender, senderEmail, recipient, recipientEmail string, data RejectRegistrationData) (message *mail.SGMailV3, err error)
RejectRegistrationEmail creates a new reject registration email, ready for sending by rendering the text and html templates with the supplied data then constructing a sendgrid email.
func Render ¶
Render returns the text and html executed templates for the specified name and data. Ensure that the extension is not supplied to the render method.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory.
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively.
func ReviewRequestEmail ¶
func ReviewRequestEmail(sender, senderEmail, recipient, recipientEmail string, data ReviewRequestData) (message *mail.SGMailV3, err error)
ReviewRequestEmail creates a new review request email, ready for sending by rendering the text and html templates with the supplied data then constructing a sendgrid email.
func VerifyContactEmail ¶
func VerifyContactEmail(sender, senderEmail, recipient, recipientEmail string, data VerifyContactData) (message *mail.SGMailV3, err error)
VerifyContactEmail creates a new verify contact email, ready for sending by rendering the text and html templates with the supplied data then constructing a sendgrid email.
Types ¶
type DeliverCertsData ¶
type DeliverCertsData struct { Name string // Used to address the email VID string // The ID of the VASP/Registration CommonName string // The common name assigned to the cert SerialNumber string // The serial number of the certificate Endpoint string // The expected endpoint for the TRISA service RegisteredDirectory string // The directory name for the certificates being issued }
DeliverCertsData to complete deliver certs email templates.
type EmailClient ¶
EmailClient is an interface that can be implemented by SendGrid email clients.
type EmailManager ¶
type EmailManager struct {
// contains filtered or unexported fields
}
EmailManager allows the server to send rich emails using the SendGrid service.
func New ¶
func New(conf config.EmailConfig) (m *EmailManager, err error)
New email manager with the specified configuration.
func (*EmailManager) SendDeliverCertificates ¶
SendDeliverCertificates sends the PKCS12 encrypted certificate files to the VASP contacts as an attachment, completing the certificate issuance process. This method only sends the certificate attachment to one email (to limit the delivery of a secure email), ranking the contact emails by priority. Caller must update the VASP record on the data store after calling this function.
func (*EmailManager) SendRejectRegistration ¶
SendRejectRegistration sends a notification to all VASP contacts that their registration status is rejected without certificate issuance and explains why. Caller must update the VASP record on the data store after calling this function.
func (*EmailManager) SendReviewRequest ¶
func (m *EmailManager) SendReviewRequest(vasp *pb.VASP) (sent int, err error)
SendReviewRequest is a shortcut for iComply verification in which we simply send an email to the TRISA admins and have them manually verify registrations.
func (*EmailManager) SendVerifyContact ¶ added in v1.3.1
SendVerifyContact sends a verification email to a contact.
func (*EmailManager) SendVerifyContacts ¶
func (m *EmailManager) SendVerifyContacts(vasp *pb.VASP) (sent int, err error)
SendVerifyContacts creates a verification token for each contact in the VASP contact list and sends them the verification email with instructions on how to verify their email address. Caller must update the VASP record on the data store after calling this function.
type RejectRegistrationData ¶
type RejectRegistrationData struct { Name string // Used to address the email VID string // The ID of the VASP/Registration Reason string // A description of why the registration request was rejected }
RejectRegistrationData to complete reject registration email templates.
type ReviewRequestData ¶
type ReviewRequestData struct { VID string // The ID of the VASP/Registration Token string // The unique token needed to review the registration Request string // The review request data as a nicely formatted JSON or YAML string RegisteredDirectory string // The directory name for the review request Attachment []byte // Data to attach to the email BaseURL string // The URL of the admin review endpoint to build the AdminReviewURL }
ReviewRequestData to complete review request email templates.
func (ReviewRequestData) AdminReviewURL ¶
func (d ReviewRequestData) AdminReviewURL() string
AdminReviewURL composes a link to the VASP detail in the admin UI. If the base url is missing or can't be parsed, it logs an warning and returns empty string. The AdminReviewURL is useful, but it is not a critical error.
type VerifyContactData ¶
type VerifyContactData struct { Name string // Used to address the email Token string // The unique token needed to verify the email VID string // The ID of the VASP/Registration BaseURL string // The URL of the verify contact endpoint to build the VerifyContactURL DirectoryID string // The registered directory to build a URL accessible by the BFF }
VerifyContactData to complete the verify contact email templates.
func (VerifyContactData) VerifyContactURL ¶
func (d VerifyContactData) VerifyContactURL() string
VerifyContactURL composes the link to verify the contact from the context. If the link is not able to be composed, the function returns an empty string and logs an error because without the link the email is fairly useless.