diff --git a/account.go b/account.go index 97d3a62..e902b5b 100644 --- a/account.go +++ b/account.go @@ -876,16 +876,16 @@ func viewEditCollection(app *App, u *User, w http.ResponseWriter, r *http.Reques *Collection Silenced bool - config.LettersCfg + config.EmailCfg LetterReplyTo string }{ UserPage: NewUserPage(app, r, u, "Edit "+c.DisplayTitle(), flashes), Collection: c, Silenced: silenced, - LettersCfg: app.cfg.Letters, + EmailCfg: app.cfg.Email, } obj.UserPage.CollAlias = c.Alias - if obj.LettersCfg.Enabled() { + if obj.EmailCfg.Enabled() { obj.LetterReplyTo = app.db.GetCollectionAttribute(c.ID, collAttrLetterReplyTo) } diff --git a/app.go b/app.go index 54a6ccc..42d9891 100644 --- a/app.go +++ b/app.go @@ -428,10 +428,10 @@ func Initialize(apper Apper, debug bool) (*App, error) { initActivityPub(apper.App()) - if apper.App().cfg.Letters.Domain != "" || apper.App().cfg.Letters.MailgunPrivate != "" { - if apper.App().cfg.Letters.Domain == "" { + if apper.App().cfg.Email.Domain != "" || apper.App().cfg.Email.MailgunPrivate != "" { + if apper.App().cfg.Email.Domain == "" { log.Error("[FAILED] Starting publish jobs queue: no [letters]domain config value set.") - } else if apper.App().cfg.Letters.MailgunPrivate == "" { + } else if apper.App().cfg.Email.MailgunPrivate == "" { log.Error("[FAILED] Starting publish jobs queue: no [letters]mailgun_private config value set.") } else { log.Info("Starting publish jobs queue...") diff --git a/config/config.go b/config/config.go index 36bbc82..1afd5f3 100644 --- a/config/config.go +++ b/config/config.go @@ -170,7 +170,7 @@ type ( DisablePasswordAuth bool `ini:"disable_password_auth"` } - LettersCfg struct { + EmailCfg struct { Domain string `ini:"domain"` MailgunPrivate string `ini:"mailgun_private"` } @@ -180,7 +180,7 @@ type ( Server ServerCfg `ini:"server"` Database DatabaseCfg `ini:"database"` App AppCfg `ini:"app"` - Letters LettersCfg `ini:"letters"` + Email EmailCfg `ini:"email"` SlackOauth SlackOauthCfg `ini:"oauth.slack"` WriteAsOauth WriteAsOauthCfg `ini:"oauth.writeas"` GitlabOauth GitlabOauthCfg `ini:"oauth.gitlab"` @@ -241,7 +241,7 @@ func (ac *AppCfg) LandingPath() string { return ac.Landing } -func (lc LettersCfg) Enabled() bool { +func (lc EmailCfg) Enabled() bool { return lc.Domain != "" && lc.MailgunPrivate != "" } diff --git a/email.go b/email.go index d97ab15..551dd97 100644 --- a/email.go +++ b/email.go @@ -313,8 +313,8 @@ Originally published on ` + p.Collection.DisplayTitle() + ` (` + p.Collection.Ca Sent to %recipient.to%. Unsubscribe: ` + p.Collection.CanonicalURL() + `email/unsubscribe/%recipient.id%?t=%recipient.token%` - gun := mailgun.NewMailgun(app.cfg.Letters.Domain, app.cfg.Letters.MailgunPrivate) - m := mailgun.NewMessage(p.Collection.DisplayTitle()+" <"+p.Collection.Alias+"@"+app.cfg.Letters.Domain+">", stripmd.Strip(p.DisplayTitle()), plainMsg) + gun := mailgun.NewMailgun(app.cfg.Email.Domain, app.cfg.Email.MailgunPrivate) + m := mailgun.NewMessage(p.Collection.DisplayTitle()+" <"+p.Collection.Alias+"@"+app.cfg.Email.Domain+">", stripmd.Strip(p.DisplayTitle()), plainMsg) replyTo := app.db.GetCollectionAttribute(collID, collAttrLetterReplyTo) if replyTo != "" { m.SetReplyTo(replyTo) @@ -443,14 +443,14 @@ func sendSubConfirmEmail(app *App, c *Collection, email, subID, token string) er } // Send email - gun := mailgun.NewMailgun(app.cfg.Letters.Domain, app.cfg.Letters.MailgunPrivate) + gun := mailgun.NewMailgun(app.cfg.Email.Domain, app.cfg.Email.MailgunPrivate) plainMsg := "Confirm your subscription to " + c.DisplayTitle() + ` (` + c.CanonicalURL() + `) to start receiving future posts. Simply click the following link (or copy and paste it into your browser): ` + c.CanonicalURL() + "email/confirm/" + subID + "?t=" + token + ` If you didn't subscribe to this site or you're not sure why you're getting this email, you can delete it. You won't be subscribed or receive any future emails.` - m := mailgun.NewMessage(c.DisplayTitle()+" <"+c.Alias+"@"+app.cfg.Letters.Domain+">", "Confirm your subscription to "+c.DisplayTitle(), plainMsg, fmt.Sprintf("<%s>", email)) + m := mailgun.NewMessage(c.DisplayTitle()+" <"+c.Alias+"@"+app.cfg.Email.Domain+">", "Confirm your subscription to "+c.DisplayTitle(), plainMsg, fmt.Sprintf("<%s>", email)) m.AddTag("Email Verification") m.SetHtml(` diff --git a/posts.go b/posts.go index 6b94cf8..fc8eddc 100644 --- a/posts.go +++ b/posts.go @@ -657,7 +657,7 @@ func newPost(app *App, w http.ResponseWriter, r *http.Request) error { if !app.cfg.App.Private && app.cfg.App.Federation && !newPost.Created.After(time.Now()) { go federatePost(app, newPost, newPost.Collection.ID, false) } - if app.cfg.Letters.Enabled() && newPost.Collection.EmailSubsEnabled() { + if app.cfg.Email.Enabled() && newPost.Collection.EmailSubsEnabled() { go app.db.InsertJob(&PostJob{ PostID: newPost.ID, Action: "email", @@ -973,7 +973,7 @@ func addPost(app *App, w http.ResponseWriter, r *http.Request) error { go federatePost(app, pRes.Post, pRes.Post.Collection.ID, false) } } - if app.cfg.Letters.Enabled() && pRes.Post.Collection.EmailSubsEnabled() { + if app.cfg.Email.Enabled() && pRes.Post.Collection.EmailSubsEnabled() { go app.db.InsertJob(&PostJob{ PostID: pRes.Post.ID, Action: "email", @@ -1558,7 +1558,7 @@ Are you sure it was ever here?`, } else { p.extractData() p.Content = strings.Replace(p.Content, "", "", 1) - if app.cfg.Letters.Enabled() && c.EmailSubsEnabled() { + if app.cfg.Email.Enabled() && c.EmailSubsEnabled() { // TODO: indicate plan is inactive or subs disabled when OWNER is viewing their own post. if u != nil && u.IsEmailSubscriber(app, c.ID) { p.Content = strings.Replace(p.Content, "", `
You're subscribed to email updates. Unsubscribe.
`, -1)