feat(notification): add enotify sieve script

This commit is contained in:
Hivert Quentin
2023-08-29 10:07:53 +02:00
parent 4f7c73143f
commit 82b69d1414
16 changed files with 223 additions and 21 deletions
+1
View File
@@ -53,6 +53,7 @@
- (BOOL) forwardEnabled;
- (int) forwardConstraints;
- (NSArray *) forwardConstraintsDomains;
- (BOOL) notificationEnabled;
- (BOOL) vacationEnabled;
- (BOOL) vacationPeriodEnabled;
- (NSString *) vacationDefaultSubject;
+5
View File
@@ -225,6 +225,11 @@
return [self stringArrayForKey: @"SOGoForwardConstraintsDomains"];
}
- (BOOL) notificationEnabled
{
return [self boolForKey: @"SOGoNotificationEnabled"];
}
- (BOOL) vacationEnabled
{
return [self boolForKey: @"SOGoVacationEnabled"];
+42 -2
View File
@@ -206,7 +206,7 @@ static NSString *sieveScriptName = @"sogo";
@"imapflags", @"removeflag",
@"imapflags", @"flag",
@"vacation", @"vacation",
@"notify", @"notify",
@"notify", @"enotify",
@"fileinto", @"fileinto",
@"reject", @"reject",
@"regex", @"regex",
@@ -543,6 +543,12 @@ static NSString *sieveScriptName = @"sogo";
else if ([method isEqualToString: @"redirect"])
sieveAction = [NSString stringWithFormat: @"%@ %@",
method, [argument asSieveQuotedString]];
else if ([method isEqualToString: @"notify"])
{
argument = [NSString stringWithFormat: @"mailto:%@", argument];
sieveAction = [NSString stringWithFormat: @"%@ %@",
method, [argument asSieveQuotedString]];
}
else if ([method isEqualToString: @"reject"])
sieveAction = [NSString stringWithFormat: @"%@ %@",
method, [argument asSieveQuotedString]];
@@ -863,7 +869,7 @@ static NSString *sieveScriptName = @"sogo";
error = nil;
dd = [user domainDefaults];
if (!([dd sieveScriptsEnabled] || [dd vacationEnabled] || [dd forwardEnabled]))
if (!([dd sieveScriptsEnabled] || [dd vacationEnabled] || [dd forwardEnabled] || [dd notificationEnabled]))
return error;
req = [NSMutableArray arrayWithCapacity: 15];
@@ -1207,6 +1213,40 @@ static NSString *sieveScriptName = @"sogo";
}
}
// We handle mail notification
values = [ud notificationOptions];
if (values && [[values objectForKey: @"enabled"] boolValue])
{
// BOOL alwaysSend;
NSString *notify;
id addresses;
int i;
// alwaysSend = [[values objectForKey: @"alwaysSend"] boolValue];
b = YES;
[req addObjectUniquely: @"enotify"];
addresses = [values objectForKey: @"notificationAddress"];
if ([addresses isKindOfClass: [NSString class]])
addresses = [addresses componentsSeparatedByString: @","];
for (i = 0; i < [addresses count]; i++)
{
v = [addresses objectAtIndex: i];
if (v && [v length] > 0)
{
notify = [NSString stringWithFormat: @"notify \"mailto:%@\";\r\n", v];
// if (alwaysSend)
// [script insertString: notify atIndex: 0];
// else
[script appendString: notify];
}
}
}
// We handle header/footer Sieve scripts
if ((v = [dd sieveScriptHeaderTemplateFile]))
{
+3
View File
@@ -222,6 +222,9 @@ extern NSString *SOGoPasswordRecoverySecondaryEmail;
- (void) setForwardOptions: (NSDictionary *) newValue;
- (NSDictionary *) forwardOptions;
- (void) setNotificationOptions: (NSDictionary *) newValue;
- (NSDictionary *) notificationOptions;
- (void) setMailLabelsColors: (NSDictionary *) newValues;
- (NSDictionary *) mailLabelsColors;
+10
View File
@@ -989,6 +989,16 @@ NSString *SOGoPasswordRecoverySecondaryEmail = @"SecondaryEmail";
return [self dictionaryForKey: @"Forward"];
}
- (void) setNotificationOptions: (NSDictionary *) newValue
{
[self setObject: newValue forKey: @"Notification"];
}
- (NSDictionary *) notificationOptions
{
return [self dictionaryForKey: @"Notification"];
}
- (void) setContactsCategories: (NSArray *) newValues
{
[self setObject: newValues forKey: @"SOGoContactsCategories"];