Skip to content

Commit

Permalink
feat(mail): always forward incoming messages, before all filters
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cgx committed Apr 6, 2022
1 parent 44afac0 commit 8ed4fc8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
22 changes: 17 additions & 5 deletions SoObjects/SOGo/SOGoSieveManager.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* SOGoSieveManager.m - this file is part of SOGo
*
* Copyright (C) 2010-2019 Inverse inc.
*
* Author: Inverse <[email protected]>
* 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
Expand Down Expand Up @@ -1159,9 +1157,12 @@ - (NSException *) updateFiltersForAccount: (SOGoMailAccount *) theAccount

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"];
Expand All @@ -1172,11 +1173,22 @@ - (NSException *) updateFiltersForAccount: (SOGoMailAccount *) theAccount
{
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
Expand Down
2 changes: 2 additions & 0 deletions UI/PreferencesUI/English.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
10 changes: 10 additions & 0 deletions UI/Templates/PreferencesUI/UIxPreferences.wox
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 8ed4fc8

Please sign in to comment.