-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
86 lines (66 loc) · 2.21 KB
/
models.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package mmailer
import (
"fmt"
)
type Address struct {
Name string `json:"name"`
Email string `json:"email"`
}
func (a Address) String() string {
if len(a.Name) == 0 {
return a.Email
}
return fmt.Sprintf("\"%s\" <%s>", a.Name, a.Email)
}
type Email struct {
Headers map[string]string `json:"headers"`
From Address `json:"from"`
To []Address `json:"to"`
Cc []Address `json:"cc"`
Subject string `json:"subject"`
Text string `json:"text"`
Html string `json:"html"`
}
func NewEmail() Email {
return Email{
Headers: map[string]string{},
}
}
type Response struct {
Service string `json:"service"`
MessageId string `json:"message_id"`
Email string `json:"email"`
}
func (r Response) Id() string {
return fmt.Sprintf("%s:%s", r.Service, r.MessageId)
}
type PosthookEvent string
func (p PosthookEvent) String() string {
return string(p)
}
// Message has been successfully delivered to the receiving server.
const EventDelivered PosthookEvent = "delivered"
//Recipient's email server temporarily rejected message.
const EventDeferred PosthookEvent = "deferred"
//Receiving server could not or would not accept message.
const EventBounce PosthookEvent = "bounce"
const EventDropped PosthookEvent = "dropped"
//Recipient has opened the HTML message. You need to enable Open Tracking for getting this type of event.
const EventOpen PosthookEvent = "open"
//Recipient clicked on a link within the message. You need to enable Click Tracking for getting this type of event.
const EventClick PosthookEvent = "click"
//Recipient marked a message as spam.
const EventSpam PosthookEvent = "spam"
//Recipient clicked on message's subscription management link. You need to enable Subscription Tracking for getting this type of event.
const EventUnsubscribe PosthookEvent = "unsubscribe"
const EventUnknown PosthookEvent = "unknown"
type Posthook struct {
Service string `json:"service"`
MessageId string `json:"message_id"`
Email string `json:"email"`
Event PosthookEvent `json:"event"`
Info string `json:"info,omitempty"`
}
func (r Posthook) Id() string {
return fmt.Sprintf("%s:%s", r.Service, r.MessageId)
}