-
Notifications
You must be signed in to change notification settings - Fork 20
/
email_sent.go
41 lines (35 loc) · 1.02 KB
/
email_sent.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package events
import (
"github.com/nyaruka/goflow/flows"
)
func init() {
registerType(TypeEmailSent, func() flows.Event { return &EmailSentEvent{} })
}
// TypeEmailSent is our type for the email event
const TypeEmailSent string = "email_sent"
// EmailSentEvent events are created when an action has sent an email.
//
// {
// "type": "email_sent",
// "created_on": "2006-01-02T15:04:05Z",
// "to": ["foo@bar.com"],
// "subject": "Your activation token",
// "body": "Your activation token is AAFFKKEE"
// }
//
// @event email_sent
type EmailSentEvent struct {
baseEvent
To []string `json:"to" validate:"required,min=1"`
Subject string `json:"subject" validate:"required"`
Body string `json:"body"`
}
// NewEmailSent returns a new email event with the passed in subject, body and emails
func NewEmailSent(to []string, subject string, body string) *EmailSentEvent {
return &EmailSentEvent{
baseEvent: newBaseEvent(TypeEmailSent),
To: to,
Subject: subject,
Body: body,
}
}