From 02dd5c3501b1123e66c79dbc5d640ce6391ec008 Mon Sep 17 00:00:00 2001 From: y9048a Date: Thu, 21 Nov 2024 11:52:51 +0100 Subject: [PATCH] feat(mail) Introduce option SOGoVacationAllowZeroDays to allow a sieve vacation days value of 0 --- Documentation/SOGoInstallationGuide.asciidoc | 10 ++++++++++ SoObjects/SOGo/SOGoDomainDefaults.h | 1 + SoObjects/SOGo/SOGoDomainDefaults.m | 12 ++++++++++++ SoObjects/SOGo/SOGoSieveManager.m | 4 ++-- UI/PreferencesUI/UIxPreferences.m | 8 ++++++-- UI/Templates/PreferencesUI/UIxPreferences.wox | 9 +++++++-- 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/Documentation/SOGoInstallationGuide.asciidoc b/Documentation/SOGoInstallationGuide.asciidoc index 130261fd8..1474d09ce 100644 --- a/Documentation/SOGoInstallationGuide.asciidoc +++ b/Documentation/SOGoInstallationGuide.asciidoc @@ -2443,6 +2443,16 @@ appended to the user's vacation message. For example: See `SOGoVacationHeaderTemplateFile` for available template variables. +|D |SOGoVacationAllowZeroDays +|Parameter used to enable an option of 0 for the vacation days setting. +A value of 0 means that auto response mails are sent for every incoming mail. + +This option has to be supported by the IMAP host +(see https://doc.dovecot.org/2.3/settings/pigeonhole-ext/vacation/#pigeonhole_setting-sieve_vacation_min_period +for instructions regarding Dovecot/Pigeonhole). + +Defaults to `NO` when unset. + |D |SOGoForwardEnabled |Parameter used to activate the edition from the preferences window of a forwarding email address. Requires Sieve script support on the IMAP diff --git a/SoObjects/SOGo/SOGoDomainDefaults.h b/SoObjects/SOGo/SOGoDomainDefaults.h index c7fe90199..03434873a 100644 --- a/SoObjects/SOGo/SOGoDomainDefaults.h +++ b/SoObjects/SOGo/SOGoDomainDefaults.h @@ -60,6 +60,7 @@ - (NSString *) vacationDefaultSubject; - (NSString *) vacationHeaderTemplateFile; - (NSString *) vacationFooterTemplateFile; +- (BOOL) vacationAllowZeroDays; - (NSString *) mailingMechanism; - (NSString *) smtpServer; - (BOOL)smtpMasterUserEnabled; diff --git a/SoObjects/SOGo/SOGoDomainDefaults.m b/SoObjects/SOGo/SOGoDomainDefaults.m index 089296528..1d4848d4c 100644 --- a/SoObjects/SOGo/SOGoDomainDefaults.m +++ b/SoObjects/SOGo/SOGoDomainDefaults.m @@ -277,6 +277,18 @@ return [self stringForKey: @"SOGoVacationFooterTemplateFile"]; } +- (BOOL) vacationAllowZeroDays +{ + id o; + + o = [self stringForKey: @"SOGoVacationAllowZeroDays"]; + + if (o) + return [o boolValue]; + + return NO; +} + - (NSString *) mailingMechanism { NSString *mailingMechanism; diff --git a/SoObjects/SOGo/SOGoSieveManager.m b/SoObjects/SOGo/SOGoSieveManager.m index 2b2962cc0..b42f09406 100644 --- a/SoObjects/SOGo/SOGoSieveManager.m +++ b/SoObjects/SOGo/SOGoSieveManager.m @@ -1016,8 +1016,8 @@ static NSString *sieveScriptName = @"sogo"; text = [NSString stringWithFormat: @"%@%@", text, [templateFile textForUser: user]]; } - if (days == 0) - days = 7; + if (days <= 0) + days = [dd vacationAllowZeroDays] ? 0 : 7; vacation_script = [NSMutableString string]; diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m index dcadd594b..9e2e66bf8 100644 --- a/UI/PreferencesUI/UIxPreferences.m +++ b/UI/PreferencesUI/UIxPreferences.m @@ -1000,12 +1000,16 @@ static NSArray *reminderValues = nil; // - (NSArray *) daysBetweenResponsesList { - static NSArray *daysBetweenResponses = nil; + static NSMutableArray *daysBetweenResponses = nil; if (!daysBetweenResponses) { - daysBetweenResponses = [NSArray arrayWithObjects: @"1", @"2", @"3", + daysBetweenResponses = [NSMutableArray arrayWithObjects: @"1", @"2", @"3", @"5", @"7", @"14", @"21", @"30", nil]; + if ([[user domainDefaults] vacationAllowZeroDays]) + { + [daysBetweenResponses insertObject:@"0" atIndex:0]; + } [daysBetweenResponses retain]; } diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index e26230dcd..6cb676955 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -1175,7 +1175,12 @@ ng-model="app.preferences.defaults.Vacation.daysBetweenResponse"> - + + + + + + @@ -1499,4 +1504,4 @@ - \ No newline at end of file +