/
email.go
47 lines (41 loc) · 965 Bytes
/
email.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
package forms
import (
"fmt"
log "github.com/Sirupsen/logrus"
"github.com/kapmahc/fly/plugins/auth"
"github.com/kapmahc/fly/web"
"github.com/kapmahc/fly/web/job"
)
const (
actApply = "apply"
actCancel = "cancel"
)
func (p *Plugin) _sendEmail(lng string, form *Form, record *Record, act string) {
obj := struct {
Home string
Title string
Apply string
Cancel string
}{
Home: web.Home(),
Title: form.Title,
Apply: fmt.Sprintf("/forms/apply/%d", form.ID),
Cancel: fmt.Sprintf("/forms/cancel/%d", form.ID),
}
subject, err := p.I18n.F(lng, fmt.Sprintf("forms.emails.%s.subject", act), obj)
if err != nil {
log.Error(err)
return
}
body, err := p.I18n.F(lng, fmt.Sprintf("forms.emails.%s.body", act), obj)
if err != nil {
log.Error(err)
return
}
// -----------------------
p.Server.Send(job.PriorityLow, auth.SendEmailJob, map[string]string{
"to": record.Email,
"subject": subject,
"body": body,
})
}