From dc81f70928afeddbce0f1dbebb7552e298ff99b2 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 25 May 2021 14:17:12 -0400 Subject: [PATCH] fix(mail): use default signature when forcing default identity --- SoObjects/Mailer/SOGoMailForward.h | 2 +- SoObjects/Mailer/SOGoMailForward.m | 32 +++++++++++++++++------------- UI/PreferencesUI/UIxPreferences.m | 4 ++-- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/SoObjects/Mailer/SOGoMailForward.h b/SoObjects/Mailer/SOGoMailForward.h index f149dd7fe..33c7f4aae 100644 --- a/SoObjects/Mailer/SOGoMailForward.h +++ b/SoObjects/Mailer/SOGoMailForward.h @@ -30,7 +30,7 @@ SOGoMailObject *sourceMail; NSString *field; NSString *currentValue; - BOOL htmlComposition; + BOOL htmlComposition, forceDefaultIdentity; NSString *signaturePlacement; } diff --git a/SoObjects/Mailer/SOGoMailForward.m b/SoObjects/Mailer/SOGoMailForward.m index 2b69cbb17..d71367998 100644 --- a/SoObjects/Mailer/SOGoMailForward.m +++ b/SoObjects/Mailer/SOGoMailForward.m @@ -42,8 +42,8 @@ if ((self = [super init])) { ud = [[context activeUser] userDefaults]; - htmlComposition - = [[ud mailComposeMessageType] isEqualToString: @"html"]; + htmlComposition = [[ud mailComposeMessageType] isEqualToString: @"html"]; + forceDefaultIdentity = [ud mailForceDefaultIdentity]; sourceMail = nil; currentValue = nil; } @@ -243,23 +243,27 @@ NSString *email, *signature, *mailSignature, *nl, *space; int count, max; - fromSentMailbox = [[sourceMail container] isKindOfClass: [SOGoSentFolder class]]; - if (fromSentMailbox) - addresses = [sourceMail fromEnvelopeAddresses]; - else - addresses = [sourceMail toEnvelopeAddresses]; identity = nil; mailSignature = @""; - max = [addresses count]; - if (max) + if (!forceDefaultIdentity) { - // Pick the first email matching one of the account's identities - for (count = 0; !identity && count < max; count++) + fromSentMailbox = [[sourceMail container] isKindOfClass: [SOGoSentFolder class]]; + if (fromSentMailbox) + addresses = [sourceMail fromEnvelopeAddresses]; + else + addresses = [sourceMail toEnvelopeAddresses]; + max = [addresses count]; + + if (max) { - address = [addresses objectAtIndex: count]; - email = [address baseEMail]; - identity = [[sourceMail mailAccountFolder] identityForEmail: email]; + // Pick the first email matching one of the account's identities + for (count = 0; !identity && count < max; count++) + { + address = [addresses objectAtIndex: count]; + email = [address baseEMail]; + identity = [[sourceMail mailAccountFolder] identityForEmail: email]; + } } } diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m index b33e694b8..2eb61adb7 100644 --- a/UI/PreferencesUI/UIxPreferences.m +++ b/UI/PreferencesUI/UIxPreferences.m @@ -1309,8 +1309,8 @@ static NSArray *reminderValues = nil; [target setObject: identities forKey: @"SOGoMailIdentities"]; if ([[account objectForKey: @"forceDefaultIdentity"] boolValue]) [target setObject: [NSNumber numberWithBool: YES] forKey: @"SOGoMailForceDefaultIdentity"]; - else if ([target objectForKey: @"SOGoMailforceDefaultIdentity"]) - [target removeObjectForKey: @"SOGoMailforceDefaultIdentity"]; + else if ([target objectForKey: @"SOGoMailForceDefaultIdentity"]) + [target removeObjectForKey: @"SOGoMailForceDefaultIdentity"]; [self _extractMainReceiptsPreferences: [account objectForKey: @"receipts"] inDictionary: target]; [self _extractMainSecurityPreferences: [account objectForKey: @"security"] inDictionary: target]; }