mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-13 02:43:17 +00:00
feat(notification): add enotify sieve script
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
- (BOOL) forwardEnabled;
|
||||
- (int) forwardConstraints;
|
||||
- (NSArray *) forwardConstraintsDomains;
|
||||
- (BOOL) notificationEnabled;
|
||||
- (BOOL) vacationEnabled;
|
||||
- (BOOL) vacationPeriodEnabled;
|
||||
- (NSString *) vacationDefaultSubject;
|
||||
|
||||
@@ -225,6 +225,11 @@
|
||||
return [self stringArrayForKey: @"SOGoForwardConstraintsDomains"];
|
||||
}
|
||||
|
||||
- (BOOL) notificationEnabled
|
||||
{
|
||||
return [self boolForKey: @"SOGoNotificationEnabled"];
|
||||
}
|
||||
|
||||
- (BOOL) vacationEnabled
|
||||
{
|
||||
return [self boolForKey: @"SOGoVacationEnabled"];
|
||||
|
||||
@@ -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]))
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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"];
|
||||
|
||||
Reference in New Issue
Block a user