From 11bbdee143eca65c3df564cdf6adb55fd740c841 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Fri, 26 Jun 2020 15:23:10 -0400 Subject: [PATCH] feat(mail): handle multiple mail identities If no custom identity exists, initialize the mail identities of the user with all the user's email addresses (extracted from MailFieldNames). For this code path to be executed, the user must not have any of the following defaults keys: SOGoMailIdentities SOGoMailCustomFullName SOGoMailCustomEmail SOGoMailReplyTo SOGoMailSignature Fixes #768, fixes #4602 --- SoObjects/SOGo/SOGoUser.m | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index d92abb5b6..03a366c2a 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -786,20 +786,28 @@ if (![identities count]) { - // Create a default identity - identity = [NSMutableDictionary dictionaryWithObjectsAndKeys: - fullName, @"fullName", - [self systemEmail], @"email", nil]; - if (appendDeletegatedIdentities) + // Create an identity for each email address + max = [mails count]; + for (count = 0; count < max; count++) { - [identity setObject: [NSNumber numberWithBool: YES] forKey: @"isDefault"]; - hasDefaultIdentity = YES; + identity = [NSMutableDictionary dictionaryWithObjectsAndKeys: + fullName, @"fullName", + [mails objectAtIndex: count], @"email", nil]; + if (appendDeletegatedIdentities) + { + if (count == 0) + { + // First identity uses the system email -- mark it as the default + [identity setObject: [NSNumber numberWithBool: YES] forKey: @"isDefault"]; + hasDefaultIdentity = YES; + } + } + else + { + [identity setObject: [NSNumber numberWithBool: YES] forKey: @"isReadOnly"]; + } + [identities addObject: identity]; } - else - { - [identity setObject: [NSNumber numberWithBool: YES] forKey: @"isReadOnly"]; - } - [identities addObject: identity]; } /* identities from delegators */