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 committed 2022-04-06 15:43:07 -04:00
1 parent 44afac0715
commit 8ed4fc88b5
3 files changed
+29 -5

No files matched your search

+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