Add config to disable it

This commit is contained in:
kolaente 2020-12-18 19:32:53 +01:00
parent 7c1836f188
commit 1ff0167f1a
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 16 additions and 1 deletions

View File

@ -39,6 +39,9 @@ service:
# each request made to this endpoint neefs to provide an `Authorization: <token>` header with the token from below. <br/>
# **You should never use this unless you know exactly what you're doing**
testingtoken: ''
# If enabled, vikunja will send an email to everyone who is either assigned to a task or created it when a task reminder
# is due.
enableemailreminders: true
database:
# Database type to use. Supported types are mysql, postgres and sqlite.

View File

@ -170,6 +170,13 @@ each request made to this endpoint neefs to provide an `Authorization: <token>`
Default: `<empty>`
### enableemailreminders
If enabled, vikunja will send an email to everyone who is either assigned to a task or created it when a task reminder
is due.
Default: `true`
---
## database

View File

@ -52,6 +52,7 @@ const (
ServiceEnableTotp Key = `service.enabletotp`
ServiceSentryDsn Key = `service.sentrydsn`
ServiceTestingtoken Key = `service.testingtoken`
ServiceEnableEmailReminders Key = `service.enableemailreminders`
AuthLocalEnabled Key = `auth.local.enabled`
AuthOpenIDEnabled Key = `auth.openid.enabled`
@ -233,6 +234,7 @@ func InitDefaultConfig() {
ServiceTimeZone.setDefault("GMT")
ServiceEnableTaskComments.setDefault(true)
ServiceEnableTotp.setDefault(true)
ServiceEnableEmailReminders.setDefault(false)
// Auth
AuthLocalEnabled.setDefault(true)

View File

@ -87,6 +87,10 @@ func getTaskUsersForTasks(taskIDs []int64) (taskUsers []*taskUser, err error) {
// RegisterReminderCron registers a cron function which runs every minute to check if any reminders are due the
// next minute to send emails.
func RegisterReminderCron() {
if !config.ServiceEnableEmailReminders.GetBool() {
return
}
if !config.MailerEnabled.GetBool() {
log.Info("Mailer is disabled, not sending reminders per mail")
return
@ -140,7 +144,6 @@ func RegisterReminderCron() {
mail.SendMailWithTemplate(u.User.Email, `Reminder for "`+u.Task.Title+`"`, "reminder-email", data)
log.Debugf("[Task Reminder Cron] Sent reminder email for task %d to user %d", u.Task.ID, u.User.ID)
}
})
if err != nil {
log.Fatalf("Could not register reminder cron: %s", err)