Add option on UI to toggle update checks.

Closes #326
This commit is contained in:
Kailash Nadh 2021-05-16 16:54:55 +05:30
parent d695bb34cc
commit 95a81d17ce
16 changed files with 47 additions and 6 deletions

View file

@ -222,9 +222,9 @@ func initQueries(sqlFile string, db *sqlx.DB, fs stuffbin.FileSystem, prepareQue
}
// initSettings loads settings from the DB.
func initSettings(q *Queries) {
func initSettings(q *sqlx.Stmt) {
var s types.JSONText
if err := q.GetSettings.Get(&s); err != nil {
if err := q.Get(&s); err != nil {
lo.Fatalf("error reading settings from DB: %s", pqErrMsg(err))
}

View file

@ -135,7 +135,7 @@ func init() {
_, queries := initQueries(queryFilePath, db, fs, true)
// Load settings from DB.
initSettings(queries)
initSettings(queries.GetSettings)
}
func main() {
@ -180,7 +180,9 @@ func main() {
srv := initHTTPServer(app)
// Star the update checker.
go checkUpdates(versionString, time.Hour*24, app)
if ko.Bool("app.check_updates") {
go checkUpdates(versionString, time.Hour*24, app)
}
// Wait for the reload signal with a callback to gracefully shut down resources.
// The `wait` channel is passed to awaitReload to wait for the callback to finish

View file

@ -20,6 +20,7 @@ type settings struct {
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"`
AppBatchSize int `json:"app.batch_size"`

View file

@ -59,6 +59,12 @@
name="app.enable_public_subscription_page" />
</b-field>
<b-field :label="$t('settings.general.checkUpdates')"
:message="$t('settings.general.checkUpdatesHelp')">
<b-switch v-model="form['app.check_updates']"
name="app.check_updates" />
</b-field>
<hr />
<b-field :label="$t('settings.general.language')" label-position="on-border">
<b-select v-model="form['app.lang']" name="app.lang">

View file

@ -279,6 +279,8 @@
"settings.errorNoSMTP": "Mindestens ein SMTP Block muss aktiviert sein",
"settings.general.adminNotifEmails": "Admin Benachrichtigungen",
"settings.general.adminNotifEmailsHelp": "Komma getrennte Liste von E-Mail Adressen welche Admin Benachrichtigungen erhalten. Wie Importupdates, Fertigstellung von Kapganen, Fehler usw.",
"settings.general.checkUpdates": "Check for updates",
"settings.general.checkUpdatesHelp": "Periodically check for new app releases and notify.",
"settings.general.enablePublicSubPage": "Enable public subscription page",
"settings.general.enablePublicSubPageHelp": "Show a public subscription page with all the public lists for people to subscribe.",
"settings.general.faviconURL": "Favicon URL",

View file

@ -279,6 +279,8 @@
"settings.errorNoSMTP": "At least one SMTP block should be enabled",
"settings.general.adminNotifEmails": "Admin notification e-mails",
"settings.general.adminNotifEmailsHelp": "Comma separated list of e-mail addresses to which admin notifications such as import updates, campaign completion, failure etc. should be sent.",
"settings.general.checkUpdates": "Check for updates",
"settings.general.checkUpdatesHelp": "Periodically check for new app releases and notify.",
"settings.general.enablePublicSubPage": "Enable public subscription page",
"settings.general.enablePublicSubPageHelp": "Show a public subscription page with all the public lists for people to subscribe.",
"settings.general.faviconURL": "Favicon URL",

View file

@ -279,6 +279,8 @@
"settings.errorNoSMTP": "Al menos un bloque SMTP debe estar habilitado",
"settings.general.adminNotifEmails": "Correos electrónicos para notificacion de administradores",
"settings.general.adminNotifEmailsHelp": "Lista de correos electrónicos separados por comas, a donde las notificaciones como actualizaciones de importación, campañas completadas, fallas, etc deben ser enviadas.",
"settings.general.checkUpdates": "Check for updates",
"settings.general.checkUpdatesHelp": "Periodically check for new app releases and notify.",
"settings.general.enablePublicSubPage": "Habilitar pagina publica de subscripción",
"settings.general.enablePublicSubPageHelp": "Muestra una página con todas las listas públicas para subscribirse.",
"settings.general.faviconURL": "Favicon URL",

View file

@ -279,6 +279,8 @@
"settings.errorNoSMTP": "Au moins un bloc SMTP doit être activé",
"settings.general.adminNotifEmails": "Emails pour les notifications admin",
"settings.general.adminNotifEmailsHelp": "Liste d'adresses email (séparées par des virgules) auxquelles les notifications d'admin telles que les mises à jour d'importation, fins de campagnes, échecs, etc. seront envoyées.",
"settings.general.checkUpdates": "Check for updates",
"settings.general.checkUpdatesHelp": "Periodically check for new app releases and notify.",
"settings.general.enablePublicSubPage": "Activer la page d'abonnement publique",
"settings.general.enablePublicSubPageHelp": "Afficher une page d'abonnement publique avec toutes les listes publiques auxquelles les personnes peuvent s'abonner.",
"settings.general.faviconURL": "URL du favicon",

View file

@ -279,6 +279,8 @@
"settings.errorNoSMTP": "Devi attivare almeno un blocco SMTP",
"settings.general.adminNotifEmails": "Mail di notifica amministratore",
"settings.general.adminNotifEmailsHelp": "Lista indirizzi mail separati da virgole ai quali saranno inviate notifiche di amministrazione come gli aggiornamenti di importazione, la fine della campagna, eventuali problemi ecc.",
"settings.general.checkUpdates": "Check for updates",
"settings.general.checkUpdatesHelp": "Periodically check for new app releases and notify.",
"settings.general.enablePublicSubPage": "Attiva la pagina di iscrizione pubblica",
"settings.general.enablePublicSubPageHelp": "Visualizza una pagina di iscrizione pubblica con tutte le liste pubbliche a cui è possibile iscriversi.",
"settings.general.faviconURL": "URL della favicon",

View file

@ -279,6 +279,8 @@
"settings.errorNoSMTP": "കുറഞ്ഞപക്ഷം ഒരു എസ്. എം. ടീ. പീ ബ്ലൊക്കെങ്കിലും പ്രവർത്തനക്ഷമയിരിക്കണം",
"settings.general.adminNotifEmails": "കാര്യനിര്‍വ്വാഹകർക്കുള്ള അറിയിപ്പ് ഇ-മെയിലുകൾ",
"settings.general.adminNotifEmailsHelp": "ഇംപോർട്ട് ചെയ്തതിലുള്ള വിവരങ്ങൾ, ക്യാമ്പേയ്ൻ പൂർത്തീകരണം, പ്രശ്നങ്ങൾ എന്നിങ്ങനെയുള്ള പ്രധാനപ്പെട്ട കാര്യനിര്‍വ്വാഹകർക്കുള്ള അറിയിപ്പിനായുള്ള കോമാ ഉപയോഗിച്ച് വേർതിരിച്ച ഇ-മെയിൽ വിലാസങ്ങൾ.",
"settings.general.checkUpdates": "Check for updates",
"settings.general.checkUpdatesHelp": "Periodically check for new app releases and notify.",
"settings.general.enablePublicSubPage": "Enable public subscription page",
"settings.general.enablePublicSubPageHelp": "Show a public subscription page with all the public lists for people to subscribe.",
"settings.general.faviconURL": "ഫാവ് ഐക്കൺ യൂ. ആർ. എൽ",

View file

@ -279,6 +279,8 @@
"settings.errorNoSMTP": "Co najmniej jeden blok SMTP powinien być aktywowany",
"settings.general.adminNotifEmails": "Adres email do powiadomień admina",
"settings.general.adminNotifEmailsHelp": "Lista maili oddzielona przecinkami do adminów, którym przesyłać informacje o importach, zakończonych kampaniach, błędach itd. ",
"settings.general.checkUpdates": "Check for updates",
"settings.general.checkUpdatesHelp": "Periodically check for new app releases and notify.",
"settings.general.enablePublicSubPage": "Włącz publiczną stronę subskrypcji",
"settings.general.enablePublicSubPageHelp": "Pokaż publiczną stronę do zapisu na subskrypcje publicznych list.",
"settings.general.faviconURL": "URL Favicony",

View file

@ -279,6 +279,8 @@
"settings.errorNoSMTP": "Pelo menos um bloco SMTP deve estar habilitado",
"settings.general.adminNotifEmails": "E-mails de notificação de administrador",
"settings.general.adminNotifEmailsHelp": "Lista de e-mails separados por vírgula para os quais as notificações de administração, como atualizações de importação, conclusão da campanha, falha, etc. devem ser enviadas.",
"settings.general.checkUpdates": "Check for updates",
"settings.general.checkUpdatesHelp": "Periodically check for new app releases and notify.",
"settings.general.enablePublicSubPage": "Habilitar a página pública de inscrição",
"settings.general.enablePublicSubPageHelp": "Habilitar a página pública de inscrição com todas as listas públicas para as pessoas se inscreverem.",
"settings.general.faviconURL": "URL do Favicon",

View file

@ -279,6 +279,8 @@
"settings.errorNoSMTP": "Pelo menos um bloco SMTP deve estar ativo",
"settings.general.adminNotifEmails": "Emails de notificação de administração",
"settings.general.adminNotifEmailsHelp": "Lista separada por vírgulas dos endereços de email para os quais devem ser enviadas notificações de administração como updates importantes, conclusão de campanhas, falhas, etc.",
"settings.general.checkUpdates": "Check for updates",
"settings.general.checkUpdatesHelp": "Periodically check for new app releases and notify.",
"settings.general.enablePublicSubPage": "Ativar página de subscrição pública",
"settings.general.enablePublicSubPageHelp": "Mostrar uma página de subscrição pública com todas as listas públicas para as pessoas se subscreverem.",
"settings.general.faviconURL": "URL do Favicon",

View file

@ -279,6 +279,8 @@
"settings.errorNoSMTP": "Должен быть включён минимум один блок SMTP",
"settings.general.adminNotifEmails": "Письма с уведомлениями для администратора",
"settings.general.adminNotifEmailsHelp": "Список адресов электронной почты, разделенных запятыми, на которые следует отправлять уведомления администратора, такие как обновления импорта, завершение кампании, сбой и т.д. ",
"settings.general.checkUpdates": "Check for updates",
"settings.general.checkUpdatesHelp": "Periodically check for new app releases and notify.",
"settings.general.enablePublicSubPage": "Включить публичную страницу подписки",
"settings.general.enablePublicSubPageHelp": "Показать страницу общедоступной подписки со всеми общедоступными списками, на которые можно подписаться.",
"settings.general.faviconURL": "Favicon URL",

View file

@ -8,6 +8,17 @@ import (
// V1_0_0 performs the DB migrations for v.1.0.0.
func V1_0_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {
_, err := db.Exec(`ALTER TYPE content_type ADD VALUE IF NOT EXISTS 'markdown'`)
return err
if _, err := db.Exec(`ALTER TYPE content_type ADD VALUE IF NOT EXISTS 'markdown'`); err != nil {
return err
}
if _, err := db.Exec(`
INSERT INTO settings (key, value) VALUES
('app.check_updates', 'true')
ON CONFLICT DO NOTHING;
`); err != nil {
return err
}
return nil
}

View file

@ -178,6 +178,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.check_updates', 'true'),
('app.notify_emails', '["admin1@mysite.com", "admin2@mysite.com"]'),
('app.lang', '"en"'),
('privacy.individual_tracking', 'false'),