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
pull/275/head
Francis Lachapelle 2020-06-26 15:23:10 -04:00
parent 03545151bb
commit 11bbdee143
1 changed files with 20 additions and 12 deletions

View File

@ -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 */