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.
This commit is contained in:
Francis Lachapelle
2022-04-06 15:43:07 -04:00
parent 44afac0715
commit 8ed4fc88b5
3 changed files with 29 additions and 5 deletions
+17 -5
View File
@@ -1,8 +1,6 @@
/* SOGoSieveManager.m - this file is part of SOGo
*
* Copyright (C) 2010-2019 Inverse inc.
*
* Author: Inverse <info@inverse.ca>
* 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
@@ -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";
@@ -1248,6 +1248,16 @@
</md-chips>
</md-input-container>
<div>
<md-checkbox
ng-model="app.preferences.defaults.Forward.alwaysSend"
ng-true-value="1"
ng-false-value="0">
<var:string label:value="Always forward"/>
<div class="sg-hint"><var:string label:value="Incoming messages are forwarded prior to apply your filters."/></div>
</md-checkbox>
</div>
<div>
<md-checkbox
ng-model="app.preferences.defaults.Forward.keepCopy"