Refactor {{ UnsubURL }} into a global function (breaking change)
This commit is contained in:
parent
2ee2e68230
commit
62aa31b14c
24
main.go
24
main.go
|
@ -30,16 +30,16 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type constants struct {
|
type constants struct {
|
||||||
RootURL string `koanf:"root"`
|
RootURL string `koanf:"root"`
|
||||||
LogoURL string `koanf:"logo_url"`
|
LogoURL string `koanf:"logo_url"`
|
||||||
FaviconURL string `koanf:"favicon_url"`
|
FaviconURL string `koanf:"favicon_url"`
|
||||||
UnsubscribeURL string
|
UnsubURL string
|
||||||
LinkTrackURL string
|
LinkTrackURL string
|
||||||
ViewTrackURL string
|
ViewTrackURL string
|
||||||
OptinURL string
|
OptinURL string
|
||||||
FromEmail string `koanf:"from_email"`
|
FromEmail string `koanf:"from_email"`
|
||||||
NotifyEmails []string `koanf:"notify_emails"`
|
NotifyEmails []string `koanf:"notify_emails"`
|
||||||
Privacy privacyOptions `koanf:"privacy"`
|
Privacy privacyOptions `koanf:"privacy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type privacyOptions struct {
|
type privacyOptions struct {
|
||||||
|
@ -309,7 +309,7 @@ func main() {
|
||||||
|
|
||||||
// Static URLS.
|
// Static URLS.
|
||||||
// url.com/subscription/{campaign_uuid}/{subscriber_uuid}
|
// url.com/subscription/{campaign_uuid}/{subscriber_uuid}
|
||||||
c.UnsubscribeURL = fmt.Sprintf("%s/subscription/%%s/%%s", app.Constants.RootURL)
|
c.UnsubURL = fmt.Sprintf("%s/subscription/%%s/%%s", app.Constants.RootURL)
|
||||||
|
|
||||||
// url.com/subscription/optin/{subscriber_uuid}
|
// url.com/subscription/optin/{subscriber_uuid}
|
||||||
c.OptinURL = fmt.Sprintf("%s/subscription/optin/%%s?%%s", app.Constants.RootURL)
|
c.OptinURL = fmt.Sprintf("%s/subscription/optin/%%s?%%s", app.Constants.RootURL)
|
||||||
|
@ -328,7 +328,7 @@ func main() {
|
||||||
Concurrency: ko.Int("app.concurrency"),
|
Concurrency: ko.Int("app.concurrency"),
|
||||||
MaxSendErrors: ko.Int("app.max_send_errors"),
|
MaxSendErrors: ko.Int("app.max_send_errors"),
|
||||||
FromEmail: app.Constants.FromEmail,
|
FromEmail: app.Constants.FromEmail,
|
||||||
UnsubURL: c.UnsubscribeURL,
|
UnsubURL: c.UnsubURL,
|
||||||
OptinURL: c.OptinURL,
|
OptinURL: c.OptinURL,
|
||||||
LinkTrackURL: c.LinkTrackURL,
|
LinkTrackURL: c.LinkTrackURL,
|
||||||
ViewTrackURL: c.ViewTrackURL,
|
ViewTrackURL: c.ViewTrackURL,
|
||||||
|
|
|
@ -63,8 +63,9 @@ type Message struct {
|
||||||
Subscriber *models.Subscriber
|
Subscriber *models.Subscriber
|
||||||
Body []byte
|
Body []byte
|
||||||
|
|
||||||
from string
|
from string
|
||||||
to string
|
to string
|
||||||
|
unsubURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config has parameters for configuring the manager.
|
// Config has parameters for configuring the manager.
|
||||||
|
@ -108,8 +109,9 @@ func (m *Manager) NewMessage(c *models.Campaign, s *models.Subscriber) *Message
|
||||||
Campaign: c,
|
Campaign: c,
|
||||||
Subscriber: s,
|
Subscriber: s,
|
||||||
|
|
||||||
from: c.FromEmail,
|
from: c.FromEmail,
|
||||||
to: s.Email,
|
to: s.Email,
|
||||||
|
unsubURL: fmt.Sprintf(m.cfg.UnsubURL, c.UUID, s.UUID),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,7 +424,7 @@ func (m *Manager) TemplateFuncs(c *models.Campaign) template.FuncMap {
|
||||||
fmt.Sprintf(m.cfg.ViewTrackURL, msg.Campaign.UUID, msg.Subscriber.UUID)))
|
fmt.Sprintf(m.cfg.ViewTrackURL, msg.Campaign.UUID, msg.Subscriber.UUID)))
|
||||||
},
|
},
|
||||||
"UnsubscribeURL": func(msg *Message) string {
|
"UnsubscribeURL": func(msg *Message) string {
|
||||||
return fmt.Sprintf(m.cfg.UnsubURL, c.UUID, msg.Subscriber.UUID)
|
return msg.unsubURL
|
||||||
},
|
},
|
||||||
"OptinURL": func(msg *Message) string {
|
"OptinURL": func(msg *Message) string {
|
||||||
// Add list IDs.
|
// Add list IDs.
|
||||||
|
|
Loading…
Reference in New Issue