Skip to content

Commit

Permalink
Add option to toggle sending opt-in confirmation. Closes knadh#363.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Sep 25, 2021
1 parent 51da1a1 commit e71115d
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 36 deletions.
19 changes: 10 additions & 9 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@ const (

// constants contains static, constant config values required by the app.
type constants struct {
RootURL string `koanf:"root_url"`
LogoURL string `koanf:"logo_url"`
FaviconURL string `koanf:"favicon_url"`
FromEmail string `koanf:"from_email"`
NotifyEmails []string `koanf:"notify_emails"`
EnablePublicSubPage bool `koanf:"enable_public_subscription_page"`
Lang string `koanf:"lang"`
DBBatchSize int `koanf:"batch_size"`
Privacy struct {
RootURL string `koanf:"root_url"`
LogoURL string `koanf:"logo_url"`
FaviconURL string `koanf:"favicon_url"`
FromEmail string `koanf:"from_email"`
NotifyEmails []string `koanf:"notify_emails"`
EnablePublicSubPage bool `koanf:"enable_public_subscription_page"`
SendOptinConfirmation bool `koanf:"send_optin_confirmation"`
Lang string `koanf:"lang"`
DBBatchSize int `koanf:"batch_size"`
Privacy struct {
IndividualTracking bool `koanf:"individual_tracking"`
AllowBlocklist bool `koanf:"allow_blocklist"`
AllowExport bool `koanf:"allow_export"`
Expand Down
17 changes: 9 additions & 8 deletions cmd/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ import (
)

type settings struct {
AppRootURL string `json:"app.root_url"`
AppLogoURL string `json:"app.logo_url"`
AppFaviconURL string `json:"app.favicon_url"`
AppFromEmail string `json:"app.from_email"`
AppNotifyEmails []string `json:"app.notify_emails"`
EnablePublicSubPage bool `json:"app.enable_public_subscription_page"`
CheckUpdates bool `json:"app.check_updates"`
AppLang string `json:"app.lang"`
AppRootURL string `json:"app.root_url"`
AppLogoURL string `json:"app.logo_url"`
AppFaviconURL string `json:"app.favicon_url"`
AppFromEmail string `json:"app.from_email"`
AppNotifyEmails []string `json:"app.notify_emails"`
EnablePublicSubPage bool `json:"app.enable_public_subscription_page"`
SendOptinConfirmation bool `json:"app.send_optin_confirmation"`
CheckUpdates bool `json:"app.check_updates"`
AppLang string `json:"app.lang"`

AppBatchSize int `json:"app.batch_size"`
AppConcurrency int `json:"app.concurrency"`
Expand Down
4 changes: 2 additions & 2 deletions cmd/subscribers.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func handleUpdateSubscriber(c echo.Context) error {
return err
}

if !req.PreconfirmSubs {
if !req.PreconfirmSubs && app.constants.SendOptinConfirmation {
_, _ = sendOptinConfirmation(sub, []int64(req.Lists), app)
}

Expand Down Expand Up @@ -725,7 +725,7 @@ func insertSubscriber(req subimporter.SubReq, app *App) (models.Subscriber, bool
}

hasOptin := false
if !req.PreconfirmSubs {
if !req.PreconfirmSubs && app.constants.SendOptinConfirmation {
// Send a confirmation e-mail (if there are any double opt-in lists).
num, _ := sendOptinConfirmation(sub, []int64(req.Lists), app)
hasOptin = num > 0
Expand Down
51 changes: 34 additions & 17 deletions frontend/src/views/settings/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,22 @@
placeholder='https://listmonk.yoursite.com' :maxlength="300" />
</b-field>

<b-field :label="$t('settings.general.logoURL')" label-position="on-border"
:message="$t('settings.general.logoURLHelp')">
<b-input v-model="data['app.logo_url']" name="app.logo_url"
placeholder='https://listmonk.yoursite.com/logo.png' :maxlength="300" />
</b-field>

<b-field :label="$t('settings.general.faviconURL')" label-position="on-border"
:message="$t('settings.general.faviconURLHelp')">
<b-input v-model="data['app.favicon_url']" name="app.favicon_url"
placeholder='https://listmonk.yoursite.com/favicon.png' :maxlength="300" />
</b-field>
<div class="columns">
<div class="column is-6">
<b-field :label="$t('settings.general.logoURL')" label-position="on-border"
:message="$t('settings.general.logoURLHelp')">
<b-input v-model="data['app.logo_url']" name="app.logo_url"
placeholder='https://listmonk.yoursite.com/logo.png' :maxlength="300" />
</b-field>
</div>
<div class="column is-6">
<b-field :label="$t('settings.general.faviconURL')" label-position="on-border"
:message="$t('settings.general.faviconURLHelp')">
<b-input v-model="data['app.favicon_url']" name="app.favicon_url"
placeholder='https://listmonk.yoursite.com/favicon.png' :maxlength="300" />
</b-field>
</div>
</div>

<hr />
<b-field :label="$t('settings.general.fromEmail')" label-position="on-border"
Expand All @@ -25,20 +30,32 @@
placeholder='Listmonk <[email protected]>'
pattern="(.+?)\s<(.+?)@(.+?)>" :maxlength="300" />
</b-field>

<b-field :label="$t('settings.general.adminNotifEmails')" label-position="on-border"
:message="$t('settings.general.adminNotifEmailsHelp')">
<b-taginput v-model="data['app.notify_emails']" name="app.notify_emails"
:before-adding="(v) => v.match(/(.+?)@(.+?)/)"
placeholder='[email protected]' />
</b-field>

<b-field :label="$t('settings.general.enablePublicSubPage')"
:message="$t('settings.general.enablePublicSubPageHelp')">
<b-switch v-model="data['app.enable_public_subscription_page']"
name="app.enable_public_subscription_page" />
</b-field>
<hr />
<div class="columns">
<div class="column is-6">
<b-field :label="$t('settings.general.enablePublicSubPage')"
:message="$t('settings.general.enablePublicSubPageHelp')">
<b-switch v-model="data['app.enable_public_subscription_page']"
name="app.enable_public_subscription_page" />
</b-field>
</div>
<div class="column is-6">
<b-field :label="$t('settings.general.sendOptinConfirm')"
:message="$t('settings.general.sendOptinConfirmHelp')">
<b-switch v-model="data['app.send_optin_confirmation']"
name="app.send_optin_confirmation" />
</b-field>
</div>
</div>

<hr />
<b-field :label="$t('settings.general.checkUpdates')"
:message="$t('settings.general.checkUpdatesHelp')">
<b-switch v-model="data['app.check_updates']"
Expand Down
2 changes: 2 additions & 0 deletions i18n/cs-cz.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@
"settings.general.name": "Obecné",
"settings.general.rootURL": "Kořenová adresa URL",
"settings.general.rootURLHelp": "Veřejná adresa URL instalace (bez koncového lomítka).",
"settings.general.sendOptinConfirm": "Send opt-in confirmation",
"settings.general.sendOptinConfirmHelp": "When new subscribers signup or are added via the admin form, send an opt-in confirmation e-mail.",
"settings.invalidMessengerName": "Neplatné jméno kurýra.",
"settings.mailserver.authProtocol": "Ověřovací protokol",
"settings.mailserver.host": "Hostitel",
Expand Down
2 changes: 2 additions & 0 deletions i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@
"settings.general.name": "Allgemein",
"settings.general.rootURL": "Root URL",
"settings.general.rootURLHelp": "Öffentliche URL der Installation (ohne Slash am Ende).",
"settings.general.sendOptinConfirm": "Send opt-in confirmation",
"settings.general.sendOptinConfirmHelp": "When new subscribers signup or are added via the admin form, send an opt-in confirmation e-mail.",
"settings.invalidMessengerName": "Der Name des Messengers ist ungültig",
"settings.mailserver.authProtocol": "Autentifizierungsprotokoll",
"settings.mailserver.host": "Server",
Expand Down
2 changes: 2 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@
"settings.general.name": "General",
"settings.general.rootURL": "Root URL",
"settings.general.rootURLHelp": "Public URL of the installation (no trailing slash).",
"settings.general.sendOptinConfirm": "Send opt-in confirmation",
"settings.general.sendOptinConfirmHelp": "Send an opt-in confirmation e-mail when subscribers signup via the public form or when they are added by the admin.",
"settings.invalidMessengerName": "Invalid messenger name.",
"settings.mailserver.authProtocol": "Auth protocol",
"settings.mailserver.host": "Host",
Expand Down
2 changes: 2 additions & 0 deletions i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@
"settings.general.name": "General",
"settings.general.rootURL": "URL raíz",
"settings.general.rootURLHelp": "URL pública de la instalación (sin la barra final)",
"settings.general.sendOptinConfirm": "Send opt-in confirmation",
"settings.general.sendOptinConfirmHelp": "When new subscribers signup or are added via the admin form, send an opt-in confirmation e-mail.",
"settings.invalidMessengerName": "Nombre de mensajero inválido.",
"settings.mailserver.authProtocol": "Protocolo de autenticación",
"settings.mailserver.host": "Host",
Expand Down
2 changes: 2 additions & 0 deletions i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@
"settings.general.name": "Général",
"settings.general.rootURL": "URL racine",
"settings.general.rootURLHelp": "URL publique de l'installation (sans slash final)",
"settings.general.sendOptinConfirm": "Send opt-in confirmation",
"settings.general.sendOptinConfirmHelp": "When new subscribers signup or are added via the admin form, send an opt-in confirmation e-mail.",
"settings.invalidMessengerName": "Nom de messagerie invalide",
"settings.mailserver.authProtocol": "Protocole d'authentification",
"settings.mailserver.host": "Hôte",
Expand Down
2 changes: 2 additions & 0 deletions i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@
"settings.general.name": "Generale",
"settings.general.rootURL": "Radice dell'URL",
"settings.general.rootURLHelp": "URL pubblico dell'installazione (senza barra obliqua finale).",
"settings.general.sendOptinConfirm": "Send opt-in confirmation",
"settings.general.sendOptinConfirmHelp": "When new subscribers signup or are added via the admin form, send an opt-in confirmation e-mail.",
"settings.invalidMessengerName": "Nome di messaggeria non valido.",
"settings.mailserver.authProtocol": "Protocollo di autenticazione",
"settings.mailserver.host": "Host",
Expand Down
2 changes: 2 additions & 0 deletions i18n/ml.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@
"settings.general.name": "പൊതുവായ",
"settings.general.rootURL": "റൂട്ട് യൂ. ആർ. എൽ",
"settings.general.rootURLHelp": "ഇൻസ്റ്റാളേഷന്റെ പൊതു യൂ. ആർ. എൽ (അവസാനത്തെ സ്ലാഷ് ആവശ്യമില്ല).",
"settings.general.sendOptinConfirm": "Send opt-in confirmation",
"settings.general.sendOptinConfirmHelp": "When new subscribers signup or are added via the admin form, send an opt-in confirmation e-mail.",
"settings.invalidMessengerName": "സന്ദേശവാഹകന്റെ പേര് അസാധുവാണ്",
"settings.mailserver.authProtocol": "പ്രാമാണീകരണ പ്രോട്ടോക്കോൾ",
"settings.mailserver.host": "ഹോസ്റ്റ്",
Expand Down
2 changes: 2 additions & 0 deletions i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@
"settings.general.name": "Ogólne",
"settings.general.rootURL": "Bazowy URL",
"settings.general.rootURLHelp": "Publiczny URL instalacji (bez slasha na końcu)",
"settings.general.sendOptinConfirm": "Send opt-in confirmation",
"settings.general.sendOptinConfirmHelp": "When new subscribers signup or are added via the admin form, send an opt-in confirmation e-mail.",
"settings.invalidMessengerName": "Nieprawidłowa nazwa komunikatora.",
"settings.mailserver.authProtocol": "Protokół autoryzacji",
"settings.mailserver.host": "Host",
Expand Down
2 changes: 2 additions & 0 deletions i18n/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@
"settings.general.name": "Geral",
"settings.general.rootURL": "URL base",
"settings.general.rootURLHelp": "URL público da instalação (sem barra final).",
"settings.general.sendOptinConfirm": "Send opt-in confirmation",
"settings.general.sendOptinConfirmHelp": "When new subscribers signup or are added via the admin form, send an opt-in confirmation e-mail.",
"settings.invalidMessengerName": "Nome de mensageiro inválido.",
"settings.mailserver.authProtocol": "Protocolo Autenticação",
"settings.mailserver.host": "Host",
Expand Down
2 changes: 2 additions & 0 deletions i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@
"settings.general.name": "Geral",
"settings.general.rootURL": "URL base",
"settings.general.rootURLHelp": "URL público da instalação (sem barra final).",
"settings.general.sendOptinConfirm": "Send opt-in confirmation",
"settings.general.sendOptinConfirmHelp": "When new subscribers signup or are added via the admin form, send an opt-in confirmation e-mail.",
"settings.invalidMessengerName": "Nome de mensageiro inválido.",
"settings.mailserver.authProtocol": "Protocolo Autenticação",
"settings.mailserver.host": "Host",
Expand Down
2 changes: 2 additions & 0 deletions i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@
"settings.general.name": "Основное",
"settings.general.rootURL": "Базовый URL",
"settings.general.rootURLHelp": "Публичный URL текущего портала (без конечного слэша).",
"settings.general.sendOptinConfirm": "Send opt-in confirmation",
"settings.general.sendOptinConfirmHelp": "When new subscribers signup or are added via the admin form, send an opt-in confirmation e-mail.",
"settings.invalidMessengerName": "Неверное имя мессенджера.",
"settings.mailserver.authProtocol": "Протокол авторизации",
"settings.mailserver.host": "Хост",
Expand Down
2 changes: 2 additions & 0 deletions i18n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@
"settings.general.name": "Genel",
"settings.general.rootURL": "Kök URL",
"settings.general.rootURLHelp": "Kurulumun genel URL'si (bölme çizgisi yok).",
"settings.general.sendOptinConfirm": "Send opt-in confirmation",
"settings.general.sendOptinConfirmHelp": "When new subscribers signup or are added via the admin form, send an opt-in confirmation e-mail.",
"settings.invalidMessengerName": "Geçersiz messenger adı.",
"settings.mailserver.authProtocol": "Protokol",
"settings.mailserver.host": "İstemci",
Expand Down
1 change: 1 addition & 0 deletions internal/migrations/v2.0.0.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func V2_0_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {

if _, err := db.Exec(`
INSERT INTO settings (key, value) VALUES
('app.send_optin_confirmation', 'true'),
('bounce.enabled', 'false'),
('bounce.webhooks_enabled', 'false'),
('bounce.count', '2'),
Expand Down
1 change: 1 addition & 0 deletions schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ INSERT INTO settings (key, value) VALUES
('app.message_sliding_window_duration', '"1h"'),
('app.message_sliding_window_rate', '10000'),
('app.enable_public_subscription_page', 'true'),
('app.send_optin_confirmation', 'true'),
('app.check_updates', 'true'),
('app.notify_emails', '["[email protected]", "[email protected]"]'),
('app.lang', '"en"'),
Expand Down

0 comments on commit e71115d

Please sign in to comment.