mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-09-13 17:38:01 +00:00
Merge branch 'master' into feature-5726-gab-autocomplete
This commit is contained in:
@@ -314,24 +314,54 @@
|
||||
return [[[self message] valueForKey:@"uid"] stringValue];
|
||||
}
|
||||
|
||||
- (BOOL) parseParts: (NSArray *) parts hasAttachment:(BOOL) hasAttachment {
|
||||
NSEnumerator *part;
|
||||
NSDictionary *currentPart;
|
||||
SOGoUserDefaults *ud;
|
||||
BOOL isInline;
|
||||
|
||||
ud = [[[self context] activeUser] userDefaults];
|
||||
|
||||
if ([parts count] > 1)
|
||||
{
|
||||
part = [parts objectEnumerator];
|
||||
while (!hasAttachment
|
||||
&& (currentPart = [part nextObject])) {
|
||||
if ([currentPart objectForKey: @"type"] && ![[[currentPart objectForKey: @"type"] uppercaseString] hasPrefix: @"MULTIPART"]) {
|
||||
isInline = currentPart && [currentPart objectForKey:@"disposition"]
|
||||
&& [[currentPart objectForKey:@"disposition"] objectForKey:@"type"]
|
||||
&& [[[[currentPart objectForKey:@"disposition"] objectForKey:@"type"] uppercaseString] isEqualToString:@"INLINE"];
|
||||
if (![ud hideInlineAttachments] || ([ud hideInlineAttachments] && !isInline)) {
|
||||
hasAttachment = (([currentPart objectForKey:@"disposition"]
|
||||
&& [[[currentPart objectForKey:@"disposition"] allKeys] length] > 0)
|
||||
|| ([currentPart objectForKey:@"parameterList"]
|
||||
&& [[currentPart objectForKey:@"parameterList"] objectForKey:@"name"]
|
||||
));
|
||||
}
|
||||
} else if ([currentPart objectForKey:@"parts"]) {
|
||||
hasAttachment = [self parseParts: [currentPart objectForKey:@"parts"] hasAttachment: hasAttachment];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hasAttachment;
|
||||
}
|
||||
|
||||
- (BOOL) hasMessageAttachment
|
||||
{
|
||||
NSArray *parts;
|
||||
NSEnumerator *dispositions;
|
||||
NSDictionary *currentDisp;
|
||||
BOOL hasAttachment;
|
||||
|
||||
hasAttachment = NO;
|
||||
|
||||
parts = [[message objectForKey: @"bodystructure"] objectForKey: @"parts"];
|
||||
if ([parts count] > 1)
|
||||
{
|
||||
dispositions = [[parts objectsForKey: @"disposition"
|
||||
notFoundMarker: nil] objectEnumerator];
|
||||
while (!hasAttachment
|
||||
&& (currentDisp = [dispositions nextObject]))
|
||||
hasAttachment = ([[currentDisp objectForKey: @"type"] length]);
|
||||
}
|
||||
NS_DURING
|
||||
{
|
||||
hasAttachment = [self parseParts: [[message objectForKey: @"bodystructure"] objectForKey: @"parts"] hasAttachment:hasAttachment];
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
[self logWithFormat: @"Error while parsing attachements for rendering bracket"];
|
||||
}
|
||||
NS_ENDHANDLER;
|
||||
|
||||
return hasAttachment;
|
||||
}
|
||||
|
||||
@@ -368,6 +368,9 @@ static SoProduct *preferencesProduct = nil;
|
||||
if ([[defaults source] objectForKey: @"SOGoMailAutoMarkAsReadDelay"] == nil)
|
||||
[[defaults source] setObject: [NSNumber numberWithInt: [defaults mailAutoMarkAsReadDelay]] forKey: @"SOGoMailAutoMarkAsReadDelay"];
|
||||
|
||||
if ([[defaults source] objectForKey: @"SOGoMailHideInlineAttachments"] == nil)
|
||||
[[defaults source] setObject: [NSNumber numberWithBool: [defaults hideInlineAttachments]] forKey: @"SOGoMailHideInlineAttachments"];
|
||||
|
||||
if (![[defaults source] objectForKey: @"SOGoMailAutoSave"])
|
||||
[[defaults source] setObject: [defaults mailAutoSave] forKey: @"SOGoMailAutoSave"];
|
||||
|
||||
|
||||
@@ -1532,6 +1532,44 @@ static NSArray *reminderValues = nil;
|
||||
return (forwardEnabled ? @"true" : @"false");
|
||||
}
|
||||
|
||||
- (BOOL) doForwardsMatchTheConstraints: (NSArray *) forwardMails
|
||||
{
|
||||
NSArray *allUserMails, *domainConstraints;
|
||||
NSMutableArray *allUserDomains;
|
||||
NSString *currentMail, *currentDomain, *userMail;
|
||||
SOGoDomainDefaults *dd;
|
||||
int constraint;
|
||||
|
||||
dd = [[context activeUser] domainDefaults];
|
||||
constraint = [dd forwardConstraints];
|
||||
|
||||
if(constraint > 0)
|
||||
{
|
||||
allUserMails = [[user allEmails] uniqueObjects];
|
||||
allUserDomains = [NSMutableArray array];
|
||||
for(userMail in allUserMails)
|
||||
{
|
||||
[allUserDomains push: [userMail mailDomain]];
|
||||
}
|
||||
for(currentMail in forwardMails)
|
||||
{
|
||||
currentDomain = [currentMail mailDomain];
|
||||
domainConstraints = [dd forwardConstraintsDomains];
|
||||
if (constraint == 1 && [allUserDomains indexOfObject: currentDomain] == NSNotFound)
|
||||
return NO;
|
||||
else if (constraint == 2 && [allUserDomains indexOfObject: currentDomain] != NSNotFound)
|
||||
return NO;
|
||||
else if (constraint == 2 && (!domainConstraints || [domainConstraints indexOfObject: currentDomain] == NSNotFound))
|
||||
return NO;
|
||||
else if (constraint == 3 &&
|
||||
[allUserDomains indexOfObject: currentDomain] == NSNotFound &&
|
||||
(!domainConstraints || [domainConstraints indexOfObject: currentDomain] == NSNotFound))
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /so/:username/Preferences/save Save user's defaults and settings
|
||||
* @apiVersion 1.0.0
|
||||
@@ -1561,8 +1599,8 @@ static NSArray *reminderValues = nil;
|
||||
if ((v = [o objectForKey: @"defaults"]))
|
||||
{
|
||||
NSMutableDictionary *sanitizedLabels;
|
||||
NSArray *allKeys, *accounts, *identities;
|
||||
NSDictionary *newLabels;
|
||||
NSArray *allKeys, *accounts, *identities, *forwardMails;
|
||||
NSDictionary *newLabels, *forwardPref;
|
||||
NSString *name;
|
||||
id loginModule;
|
||||
|
||||
@@ -1600,6 +1638,20 @@ static NSArray *reminderValues = nil;
|
||||
[v removeObjectForKey: @"SOGoAlternateAvatar"];
|
||||
[[[user userDefaults] source] removeObjectForKey: @"SOGoAlternateAvatar"];
|
||||
}
|
||||
|
||||
//We check if there are forward constraints
|
||||
forwardPref = [v objectForKey: @"Forward"];
|
||||
if(forwardPref && [forwardPref isKindOfClass: [NSDictionary class]]
|
||||
&& [forwardPref objectForKey: @"enabled"]
|
||||
&& [[forwardPref objectForKey: @"enabled"] boolValue])
|
||||
{
|
||||
BOOL doForward = NO;
|
||||
forwardMails = [forwardPref objectForKey: @"forwardAddress"];
|
||||
if (forwardMails && [forwardMails isKindOfClass: [NSArray class]] && [forwardMails count]>0)
|
||||
doForward = [self doForwardsMatchTheConstraints: [forwardPref objectForKey: @"forwardAddress"]];
|
||||
if(!doForward)
|
||||
[v removeObjectForKey: @"Forward"];
|
||||
}
|
||||
|
||||
if ([self userHasMailAccess])
|
||||
{
|
||||
@@ -1658,7 +1710,7 @@ static NSArray *reminderValues = nil;
|
||||
// - forceDefaultIdentity => SOGoMailForceDefaultIdentity
|
||||
// - receipts.receiptAction => SOGoMailReceiptAllow
|
||||
// - receipts.receiptNonRecipientAction => SOGoMailReceiptNonRecipientAction
|
||||
// - receipts.receiptOutsideDomainAction => SOGoMailReceiptOutsideDomainAction
|
||||
// - receipts.receiptOutsideDomaforwardAddressinAction => SOGoMailReceiptOutsideDomainAction
|
||||
// - receipts.receiptAnyAction => SOGoMailReceiptAnyAction
|
||||
// - security.alwaysSign => SOGoMailCertificateAlwaysSign
|
||||
// - security.alwaysEncrypt => SOGoMailCertificateAlwaysEncrypt
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -394,6 +394,13 @@
|
||||
$window.forwardConstraintsDomains.indexOf(domain) < 0) {
|
||||
throw new Error(l("You are not allowed to forward your messages to this domain:") + " " + domain);
|
||||
}
|
||||
else if ($window.forwardConstraints == 3 &&
|
||||
domains.indexOf(domain) < 0 &&
|
||||
($window.forwardConstraintsDomains.length > 0 &&
|
||||
$window.forwardConstraintsDomains.indexOf(domain) < 0)) {
|
||||
// If constraints mode is 3 and the domain is not an internal nor in forwardConstraintsDomains list, throw an error
|
||||
throw new Error(l("You are not allowed to forward your messages to this domain:")+ " " + domain);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user