Add option to toggle sending opt-in confirmation. Closes #363.

This commit is contained in:
Kailash Nadh 2021-09-25 10:38:13 +05:30
parent 51da1a16a0
commit e71115db26
18 changed files with 81 additions and 36 deletions

View file

@ -46,15 +46,16 @@ const (
// constants contains static, constant config values required by the app. // constants contains static, constant config values required by the app.
type constants struct { type constants struct {
RootURL string `koanf:"root_url"` RootURL string `koanf:"root_url"`
LogoURL string `koanf:"logo_url"` LogoURL string `koanf:"logo_url"`
FaviconURL string `koanf:"favicon_url"` FaviconURL string `koanf:"favicon_url"`
FromEmail string `koanf:"from_email"` FromEmail string `koanf:"from_email"`
NotifyEmails []string `koanf:"notify_emails"` NotifyEmails []string `koanf:"notify_emails"`
EnablePublicSubPage bool `koanf:"enable_public_subscription_page"` EnablePublicSubPage bool `koanf:"enable_public_subscription_page"`
Lang string `koanf:"lang"` SendOptinConfirmation bool `koanf:"send_optin_confirmation"`
DBBatchSize int `koanf:"batch_size"` Lang string `koanf:"lang"`
Privacy struct { DBBatchSize int `koanf:"batch_size"`
Privacy struct {
IndividualTracking bool `koanf:"individual_tracking"` IndividualTracking bool `koanf:"individual_tracking"`
AllowBlocklist bool `koanf:"allow_blocklist"` AllowBlocklist bool `koanf:"allow_blocklist"`
AllowExport bool `koanf:"allow_export"` AllowExport bool `koanf:"allow_export"`

View file

@ -14,14 +14,15 @@ import (
) )
type settings struct { type settings struct {
AppRootURL string `json:"app.root_url"` AppRootURL string `json:"app.root_url"`
AppLogoURL string `json:"app.logo_url"` AppLogoURL string `json:"app.logo_url"`
AppFaviconURL string `json:"app.favicon_url"` AppFaviconURL string `json:"app.favicon_url"`
AppFromEmail string `json:"app.from_email"` AppFromEmail string `json:"app.from_email"`
AppNotifyEmails []string `json:"app.notify_emails"` AppNotifyEmails []string `json:"app.notify_emails"`
EnablePublicSubPage bool `json:"app.enable_public_subscription_page"` EnablePublicSubPage bool `json:"app.enable_public_subscription_page"`
CheckUpdates bool `json:"app.check_updates"` SendOptinConfirmation bool `json:"app.send_optin_confirmation"`
AppLang string `json:"app.lang"` CheckUpdates bool `json:"app.check_updates"`
AppLang string `json:"app.lang"`
AppBatchSize int `json:"app.batch_size"` AppBatchSize int `json:"app.batch_size"`
AppConcurrency int `json:"app.concurrency"` AppConcurrency int `json:"app.concurrency"`

View file

@ -367,7 +367,7 @@ func handleUpdateSubscriber(c echo.Context) error {
return err return err
} }
if !req.PreconfirmSubs { if !req.PreconfirmSubs && app.constants.SendOptinConfirmation {
_, _ = sendOptinConfirmation(sub, []int64(req.Lists), app) _, _ = sendOptinConfirmation(sub, []int64(req.Lists), app)
} }
@ -725,7 +725,7 @@ func insertSubscriber(req subimporter.SubReq, app *App) (models.Subscriber, bool
} }
hasOptin := false hasOptin := false
if !req.PreconfirmSubs { if !req.PreconfirmSubs && app.constants.SendOptinConfirmation {
// Send a confirmation e-mail (if there are any double opt-in lists). // Send a confirmation e-mail (if there are any double opt-in lists).
num, _ := sendOptinConfirmation(sub, []int64(req.Lists), app) num, _ := sendOptinConfirmation(sub, []int64(req.Lists), app)
hasOptin = num > 0 hasOptin = num > 0

View file

@ -6,17 +6,22 @@
placeholder='https://listmonk.yoursite.com' :maxlength="300" /> placeholder='https://listmonk.yoursite.com' :maxlength="300" />
</b-field> </b-field>
<b-field :label="$t('settings.general.logoURL')" label-position="on-border" <div class="columns">
:message="$t('settings.general.logoURLHelp')"> <div class="column is-6">
<b-input v-model="data['app.logo_url']" name="app.logo_url" <b-field :label="$t('settings.general.logoURL')" label-position="on-border"
placeholder='https://listmonk.yoursite.com/logo.png' :maxlength="300" /> :message="$t('settings.general.logoURLHelp')">
</b-field> <b-input v-model="data['app.logo_url']" name="app.logo_url"
placeholder='https://listmonk.yoursite.com/logo.png' :maxlength="300" />
<b-field :label="$t('settings.general.faviconURL')" label-position="on-border" </b-field>
:message="$t('settings.general.faviconURLHelp')"> </div>
<b-input v-model="data['app.favicon_url']" name="app.favicon_url" <div class="column is-6">
placeholder='https://listmonk.yoursite.com/favicon.png' :maxlength="300" /> <b-field :label="$t('settings.general.faviconURL')" label-position="on-border"
</b-field> :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 /> <hr />
<b-field :label="$t('settings.general.fromEmail')" label-position="on-border" <b-field :label="$t('settings.general.fromEmail')" label-position="on-border"
@ -25,7 +30,6 @@
placeholder='Listmonk <noreply@listmonk.yoursite.com>' placeholder='Listmonk <noreply@listmonk.yoursite.com>'
pattern="(.+?)\s<(.+?)@(.+?)>" :maxlength="300" /> pattern="(.+?)\s<(.+?)@(.+?)>" :maxlength="300" />
</b-field> </b-field>
<b-field :label="$t('settings.general.adminNotifEmails')" label-position="on-border" <b-field :label="$t('settings.general.adminNotifEmails')" label-position="on-border"
:message="$t('settings.general.adminNotifEmailsHelp')"> :message="$t('settings.general.adminNotifEmailsHelp')">
<b-taginput v-model="data['app.notify_emails']" name="app.notify_emails" <b-taginput v-model="data['app.notify_emails']" name="app.notify_emails"
@ -33,12 +37,25 @@
placeholder='you@yoursite.com' /> placeholder='you@yoursite.com' />
</b-field> </b-field>
<b-field :label="$t('settings.general.enablePublicSubPage')" <hr />
:message="$t('settings.general.enablePublicSubPageHelp')"> <div class="columns">
<b-switch v-model="data['app.enable_public_subscription_page']" <div class="column is-6">
name="app.enable_public_subscription_page" /> <b-field :label="$t('settings.general.enablePublicSubPage')"
</b-field> :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')" <b-field :label="$t('settings.general.checkUpdates')"
:message="$t('settings.general.checkUpdatesHelp')"> :message="$t('settings.general.checkUpdatesHelp')">
<b-switch v-model="data['app.check_updates']" <b-switch v-model="data['app.check_updates']"

View file

@ -332,6 +332,8 @@
"settings.general.name": "Obecné", "settings.general.name": "Obecné",
"settings.general.rootURL": "Kořenová adresa URL", "settings.general.rootURL": "Kořenová adresa URL",
"settings.general.rootURLHelp": "Veřejná adresa URL instalace (bez koncového lomítka).", "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.invalidMessengerName": "Neplatné jméno kurýra.",
"settings.mailserver.authProtocol": "Ověřovací protokol", "settings.mailserver.authProtocol": "Ověřovací protokol",
"settings.mailserver.host": "Hostitel", "settings.mailserver.host": "Hostitel",

View file

@ -332,6 +332,8 @@
"settings.general.name": "Allgemein", "settings.general.name": "Allgemein",
"settings.general.rootURL": "Root URL", "settings.general.rootURL": "Root URL",
"settings.general.rootURLHelp": "Öffentliche URL der Installation (ohne Slash am Ende).", "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.invalidMessengerName": "Der Name des Messengers ist ungültig",
"settings.mailserver.authProtocol": "Autentifizierungsprotokoll", "settings.mailserver.authProtocol": "Autentifizierungsprotokoll",
"settings.mailserver.host": "Server", "settings.mailserver.host": "Server",

View file

@ -332,6 +332,8 @@
"settings.general.name": "General", "settings.general.name": "General",
"settings.general.rootURL": "Root URL", "settings.general.rootURL": "Root URL",
"settings.general.rootURLHelp": "Public URL of the installation (no trailing slash).", "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.invalidMessengerName": "Invalid messenger name.",
"settings.mailserver.authProtocol": "Auth protocol", "settings.mailserver.authProtocol": "Auth protocol",
"settings.mailserver.host": "Host", "settings.mailserver.host": "Host",

View file

@ -332,6 +332,8 @@
"settings.general.name": "General", "settings.general.name": "General",
"settings.general.rootURL": "URL raíz", "settings.general.rootURL": "URL raíz",
"settings.general.rootURLHelp": "URL pública de la instalación (sin la barra final)", "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.invalidMessengerName": "Nombre de mensajero inválido.",
"settings.mailserver.authProtocol": "Protocolo de autenticación", "settings.mailserver.authProtocol": "Protocolo de autenticación",
"settings.mailserver.host": "Host", "settings.mailserver.host": "Host",

View file

@ -332,6 +332,8 @@
"settings.general.name": "Général", "settings.general.name": "Général",
"settings.general.rootURL": "URL racine", "settings.general.rootURL": "URL racine",
"settings.general.rootURLHelp": "URL publique de l'installation (sans slash final)", "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.invalidMessengerName": "Nom de messagerie invalide",
"settings.mailserver.authProtocol": "Protocole d'authentification", "settings.mailserver.authProtocol": "Protocole d'authentification",
"settings.mailserver.host": "Hôte", "settings.mailserver.host": "Hôte",

View file

@ -332,6 +332,8 @@
"settings.general.name": "Generale", "settings.general.name": "Generale",
"settings.general.rootURL": "Radice dell'URL", "settings.general.rootURL": "Radice dell'URL",
"settings.general.rootURLHelp": "URL pubblico dell'installazione (senza barra obliqua finale).", "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.invalidMessengerName": "Nome di messaggeria non valido.",
"settings.mailserver.authProtocol": "Protocollo di autenticazione", "settings.mailserver.authProtocol": "Protocollo di autenticazione",
"settings.mailserver.host": "Host", "settings.mailserver.host": "Host",

View file

@ -332,6 +332,8 @@
"settings.general.name": "പൊതുവായ", "settings.general.name": "പൊതുവായ",
"settings.general.rootURL": "റൂട്ട് യൂ. ആർ. എൽ", "settings.general.rootURL": "റൂട്ട് യൂ. ആർ. എൽ",
"settings.general.rootURLHelp": "ഇൻസ്റ്റാളേഷന്റെ പൊതു യൂ. ആർ. എൽ (അവസാനത്തെ സ്ലാഷ് ആവശ്യമില്ല).", "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.invalidMessengerName": "സന്ദേശവാഹകന്റെ പേര് അസാധുവാണ്",
"settings.mailserver.authProtocol": "പ്രാമാണീകരണ പ്രോട്ടോക്കോൾ", "settings.mailserver.authProtocol": "പ്രാമാണീകരണ പ്രോട്ടോക്കോൾ",
"settings.mailserver.host": "ഹോസ്റ്റ്", "settings.mailserver.host": "ഹോസ്റ്റ്",

View file

@ -332,6 +332,8 @@
"settings.general.name": "Ogólne", "settings.general.name": "Ogólne",
"settings.general.rootURL": "Bazowy URL", "settings.general.rootURL": "Bazowy URL",
"settings.general.rootURLHelp": "Publiczny URL instalacji (bez slasha na końcu)", "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.invalidMessengerName": "Nieprawidłowa nazwa komunikatora.",
"settings.mailserver.authProtocol": "Protokół autoryzacji", "settings.mailserver.authProtocol": "Protokół autoryzacji",
"settings.mailserver.host": "Host", "settings.mailserver.host": "Host",

View file

@ -332,6 +332,8 @@
"settings.general.name": "Geral", "settings.general.name": "Geral",
"settings.general.rootURL": "URL base", "settings.general.rootURL": "URL base",
"settings.general.rootURLHelp": "URL público da instalação (sem barra final).", "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.invalidMessengerName": "Nome de mensageiro inválido.",
"settings.mailserver.authProtocol": "Protocolo Autenticação", "settings.mailserver.authProtocol": "Protocolo Autenticação",
"settings.mailserver.host": "Host", "settings.mailserver.host": "Host",

View file

@ -332,6 +332,8 @@
"settings.general.name": "Geral", "settings.general.name": "Geral",
"settings.general.rootURL": "URL base", "settings.general.rootURL": "URL base",
"settings.general.rootURLHelp": "URL público da instalação (sem barra final).", "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.invalidMessengerName": "Nome de mensageiro inválido.",
"settings.mailserver.authProtocol": "Protocolo Autenticação", "settings.mailserver.authProtocol": "Protocolo Autenticação",
"settings.mailserver.host": "Host", "settings.mailserver.host": "Host",

View file

@ -332,6 +332,8 @@
"settings.general.name": "Основное", "settings.general.name": "Основное",
"settings.general.rootURL": "Базовый URL", "settings.general.rootURL": "Базовый URL",
"settings.general.rootURLHelp": "Публичный 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.invalidMessengerName": "Неверное имя мессенджера.",
"settings.mailserver.authProtocol": "Протокол авторизации", "settings.mailserver.authProtocol": "Протокол авторизации",
"settings.mailserver.host": "Хост", "settings.mailserver.host": "Хост",

View file

@ -332,6 +332,8 @@
"settings.general.name": "Genel", "settings.general.name": "Genel",
"settings.general.rootURL": "Kök URL", "settings.general.rootURL": "Kök URL",
"settings.general.rootURLHelp": "Kurulumun genel URL'si (bölme çizgisi yok).", "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.invalidMessengerName": "Geçersiz messenger adı.",
"settings.mailserver.authProtocol": "Protokol", "settings.mailserver.authProtocol": "Protokol",
"settings.mailserver.host": "İstemci", "settings.mailserver.host": "İstemci",

View file

@ -38,6 +38,7 @@ func V2_0_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {
if _, err := db.Exec(` if _, err := db.Exec(`
INSERT INTO settings (key, value) VALUES INSERT INTO settings (key, value) VALUES
('app.send_optin_confirmation', 'true'),
('bounce.enabled', 'false'), ('bounce.enabled', 'false'),
('bounce.webhooks_enabled', 'false'), ('bounce.webhooks_enabled', 'false'),
('bounce.count', '2'), ('bounce.count', '2'),

View file

@ -183,6 +183,7 @@ INSERT INTO settings (key, value) VALUES
('app.message_sliding_window_duration', '"1h"'), ('app.message_sliding_window_duration', '"1h"'),
('app.message_sliding_window_rate', '10000'), ('app.message_sliding_window_rate', '10000'),
('app.enable_public_subscription_page', 'true'), ('app.enable_public_subscription_page', 'true'),
('app.send_optin_confirmation', 'true'),
('app.check_updates', 'true'), ('app.check_updates', 'true'),
('app.notify_emails', '["admin1@mysite.com", "admin2@mysite.com"]'), ('app.notify_emails', '["admin1@mysite.com", "admin2@mysite.com"]'),
('app.lang', '"en"'), ('app.lang', '"en"'),