From 8ed4fc88b501796e6179818c4d6279fcd458ec04 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 6 Apr 2022 15:43:07 -0400 Subject: [PATCH] feat(mail): always forward incoming messages, before all filters This new "Always forward" checkbox allows the user to forward incoming messages before evaluating the other filters, if any. When unchecked, the "redirect" directive is executed after all filters; if a filter stops evaluating the remaining rules, the message won't be forwarded. --- SoObjects/SOGo/SOGoSieveManager.m | 22 ++++++++++++++----- .../English.lproj/Localizable.strings | 2 ++ UI/Templates/PreferencesUI/UIxPreferences.wox | 10 +++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/SoObjects/SOGo/SOGoSieveManager.m b/SoObjects/SOGo/SOGoSieveManager.m index 01e5f2b68..1ac03732d 100644 --- a/SoObjects/SOGo/SOGoSieveManager.m +++ b/SoObjects/SOGo/SOGoSieveManager.m @@ -1,8 +1,6 @@ /* SOGoSieveManager.m - this file is part of SOGo * - * Copyright (C) 2010-2019 Inverse inc. - * - * Author: Inverse + * Copyright (C) 2010-2022 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1159,9 +1157,12 @@ static NSString *sieveScriptName = @"sogo"; if (values && [[values objectForKey: @"enabled"] boolValue]) { + BOOL alwaysSend; + NSString *redirect; id addresses; int i; + alwaysSend = [[values objectForKey: @"alwaysSend"] boolValue]; b = YES; addresses = [values objectForKey: @"forwardAddress"]; @@ -1172,11 +1173,22 @@ static NSString *sieveScriptName = @"sogo"; { v = [addresses objectAtIndex: i]; if (v && [v length] > 0) - [script appendFormat: @"redirect \"%@\";\r\n", v]; + { + redirect = [NSString stringWithFormat: @"redirect \"%@\";\r\n", v]; + if (alwaysSend) + [script insertString: redirect atIndex: 0]; + else + [script appendString: redirect]; + } } if ([[values objectForKey: @"keepCopy"] boolValue]) - [script appendString: @"keep;\r\n"]; + { + if (alwaysSend) + [script insertString: @"keep;\r\n" atIndex: 0]; + else + [script appendString: @"keep;\r\n"]; + } } // We handle header/footer Sieve scripts diff --git a/UI/PreferencesUI/English.lproj/Localizable.strings b/UI/PreferencesUI/English.lproj/Localizable.strings index 61243d544..3014c583c 100644 --- a/UI/PreferencesUI/English.lproj/Localizable.strings +++ b/UI/PreferencesUI/English.lproj/Localizable.strings @@ -68,6 +68,8 @@ /* forward messages */ "Forward incoming messages" = "Forward incoming messages"; +"Always forward" = "Always forward"; +"Incoming messages are forwarded prior to apply your filters." = "Incoming messages are forwarded prior to apply your filters."; "Keep a copy" = "Keep a copy"; "Enter an email" = "Enter an email"; "Add another email" = "Add another email"; diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index 58f507823..1a7229141 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -1248,6 +1248,16 @@ +
+ + +
+
+
+