Skip to content

Commit

Permalink
fix(preferences): Can not save preferences when there is a constraint…
Browse files Browse the repository at this point in the history
… on mail
  • Loading branch information
WoodySlum committed Aug 5, 2024
1 parent 58db9c9 commit 990f1e8
Showing 1 changed file with 37 additions and 30 deletions.
67 changes: 37 additions & 30 deletions UI/PreferencesUI/UIxPreferences.m
Original file line number Diff line number Diff line change
Expand Up @@ -1946,38 +1946,45 @@ - (BOOL) doForwardsMatchTheConstraints: (NSArray *) forwardMails

[[[user userDefaults] source] setValues: v];

if ([[user userDefaults] synchronize] && [self userHasMailAccess])
{
NSException *error;
SOGoMailAccount *account;
SOGoMailAccounts *folder;
SOGoDomainDefaults *dd;

dd = [[context activeUser] domainDefaults];

// We check if the Sieve server is available *ONLY* if at least one of the option is enabled
if (!([dd sieveScriptsEnabled] || [dd vacationEnabled] || [dd forwardEnabled] || [dd notificationEnabled])
|| [self _isSieveServerAvailable])
{
BOOL forceActivation = ![[v objectForKey: @"hasActiveExternalSieveScripts"] boolValue];

folder = [[[context activeUser] homeFolderInContext: context] mailAccountsFolder: @"Mail"
inContext: context];
account = [folder lookupName: @"0" inContext: context acquire: NO];

if ((error = [account updateFiltersAndForceActivation: forceActivation]))
{
results = (id <WOActionResults>) [self responseWithStatus: 500
andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: [error reason], @"message", nil]];
}
}
else
results = (id <WOActionResults>) [self responseWithStatus: 503
andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: @"Service temporarily unavailable", @"message", nil]];
} else {
if ([self userHasMailAccess]) {
if ([[user userDefaults] synchronize])
{
NSException *error;
SOGoMailAccount *account;
SOGoMailAccounts *folder;
SOGoDomainDefaults *dd;

dd = [[context activeUser] domainDefaults];

// We check if the Sieve server is available *ONLY* if at least one of the option is enabled
if (!([dd sieveScriptsEnabled] || [dd vacationEnabled] || [dd forwardEnabled] || [dd notificationEnabled])
|| [self _isSieveServerAvailable])
{
BOOL forceActivation = ![[v objectForKey: @"hasActiveExternalSieveScripts"] boolValue];

folder = [[[context activeUser] homeFolderInContext: context] mailAccountsFolder: @"Mail"
inContext: context];
account = [folder lookupName: @"0" inContext: context acquire: NO];

if ((error = [account updateFiltersAndForceActivation: forceActivation]))
{
results = (id <WOActionResults>) [self responseWithStatus: 500
andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: [error reason], @"message", nil]];
}
}
else
results = (id <WOActionResults>) [self responseWithStatus: 503
andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: @"Service temporarily unavailable", @"message", nil]];
} else {
results = (id <WOActionResults>) [self responseWithStatus: 500
andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: @"Error during the validation", @"message", nil]];
}
} else {
if (![[user userDefaults] synchronize]) {
results = (id <WOActionResults>) [self responseWithStatus: 500
andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: @"Error during the validation", @"message", nil]];
andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: @"Error during the validation", @"message", nil]];
}
}
}

if ((v = [o objectForKey: @"settings"]))
Expand Down

0 comments on commit 990f1e8

Please sign in to comment.