mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-14 11:23:19 +00:00
feat(mail): new option to force default identity
Users can now force the default identity to always be used when replying or forwarding a message.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2007-2020 Inverse inc.
|
||||
Copyright (C) 2007-2021 Inverse inc.
|
||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of SOGo.
|
||||
@@ -685,37 +685,40 @@ static NSString *userAgent = nil;
|
||||
NSDictionary *identity;
|
||||
NSMutableArray *addrs;
|
||||
NSString *email;
|
||||
SOGoMailAccount *account;
|
||||
int i;
|
||||
|
||||
/* Pick the first email matching one of the account's identities */
|
||||
addrs = [NSMutableArray array];
|
||||
if (_fromSentMailbox)
|
||||
[self _addRecipients: [_envelope from] toArray: addrs];
|
||||
else
|
||||
{
|
||||
[self _addRecipients: [_envelope to] toArray: addrs];
|
||||
if ([addrs count] == 0)
|
||||
[self _addRecipients: [_envelope cc] toArray: addrs];
|
||||
if ([addrs count] == 0)
|
||||
[self _addRecipients: [_envelope bcc] toArray: addrs];
|
||||
}
|
||||
|
||||
identity = nil;
|
||||
if ([addrs count])
|
||||
account = [[self container] mailAccountFolder];
|
||||
if (![account forceDefaultIdentity])
|
||||
{
|
||||
for (i = 0; !identity && i < [addrs count]; i++)
|
||||
/* Pick the first email matching one of the account's identities */
|
||||
addrs = [NSMutableArray array];
|
||||
if (_fromSentMailbox)
|
||||
[self _addRecipients: [_envelope from] toArray: addrs];
|
||||
else
|
||||
{
|
||||
email = [addrs objectAtIndex: i];
|
||||
identity = [[[self container] mailAccountFolder] identityForEmail: email];
|
||||
[self _addRecipients: [_envelope to] toArray: addrs];
|
||||
[self _addRecipients: [_envelope cc] toArray: addrs];
|
||||
[self _addRecipients: [_envelope bcc] toArray: addrs];
|
||||
}
|
||||
if (identity)
|
||||
|
||||
if ([addrs count])
|
||||
{
|
||||
[_info setObject: [self _emailFromIdentity: identity] forKey: @"from"];
|
||||
for (i = 0; !identity && i < [addrs count]; i++)
|
||||
{
|
||||
email = [addrs objectAtIndex: i];
|
||||
identity = [[[self container] mailAccountFolder] identityForEmail: email];
|
||||
}
|
||||
if (identity)
|
||||
{
|
||||
[_info setObject: [self _emailFromIdentity: identity] forKey: @"from"];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!identity)
|
||||
{
|
||||
identity = [[context activeUser] defaultIdentity];
|
||||
identity = [account defaultIdentity];
|
||||
if (identity)
|
||||
[_info setObject: [self _emailFromIdentity: identity] forKey: @"from"];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2009-2020 Inverse inc.
|
||||
Copyright (C) 2009-2021 Inverse inc.
|
||||
|
||||
This file is part of SOGo.
|
||||
|
||||
@@ -88,6 +88,7 @@ typedef enum {
|
||||
|
||||
- (NSArray *) identities;
|
||||
- (NSDictionary *) defaultIdentity;
|
||||
- (BOOL) forceDefaultIdentity;
|
||||
- (NSDictionary *) identityForEmail: (NSString *) email;
|
||||
- (NSString *) signature;
|
||||
- (NSString *) encryption;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2007-2020 Inverse inc.
|
||||
Copyright (C) 2007-2021 Inverse inc.
|
||||
|
||||
This file is part of SOGo.
|
||||
|
||||
@@ -694,6 +694,11 @@ static NSString *inboxFolderName = @"INBOX";
|
||||
return defaultIdentity; // can be nil
|
||||
}
|
||||
|
||||
- (BOOL) forceDefaultIdentity
|
||||
{
|
||||
return [[[self _mailAccount] objectForKey: @"forceDefaultIdentity"] boolValue];
|
||||
}
|
||||
|
||||
- (NSDictionary *) identityForEmail: (NSString *) email
|
||||
{
|
||||
NSDictionary *identity, *currentIdentity;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2006-2020 Inverse inc.
|
||||
Copyright (C) 2006-2021 Inverse inc.
|
||||
|
||||
This file is part of SOGo.
|
||||
|
||||
@@ -884,6 +884,9 @@
|
||||
[mailAccount setObject: identities forKey: @"identities"];
|
||||
[identities release];
|
||||
|
||||
if ([_defaults mailForceDefaultIdentity])
|
||||
[mailAccount setObject: [NSNumber numberWithBool: YES] forKey: @"forceDefaultIdentity"];
|
||||
|
||||
// 6. Receipts
|
||||
if ([_defaults allowUserReceipt])
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* SOGoUserDefaults.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011-2020 Inverse inc.
|
||||
* Copyright (C) 2011-2021 Inverse inc.
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -185,6 +185,9 @@ extern NSString *SOGoWeekStartFirstFullWeek;
|
||||
- (void) setMailIdentities: (NSArray *) newIdentites;
|
||||
- (NSArray *) mailIdentities;
|
||||
|
||||
- (void) setMailForceDefaultIdentity: (BOOL) newValue;
|
||||
- (BOOL) mailForceDefaultIdentity;
|
||||
|
||||
- (void) setAuxiliaryMailAccounts: (NSArray *) newAccounts;
|
||||
- (NSArray *) auxiliaryMailAccounts;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* SOGoUserDefaults.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2009-2020 Inverse inc.
|
||||
* Copyright (C) 2009-2021 Inverse inc.
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -768,6 +768,16 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
|
||||
return [self arrayForKey: @"SOGoMailIdentities"];
|
||||
}
|
||||
|
||||
- (void) setMailForceDefaultIdentity: (BOOL) newValue
|
||||
{
|
||||
[self setBool: newValue forKey: @"SOGoMailForceDefaultIdentity"];
|
||||
}
|
||||
|
||||
- (BOOL) mailForceDefaultIdentity
|
||||
{
|
||||
return [self boolForKey: @"SOGoMailForceDefaultIdentity"];
|
||||
}
|
||||
|
||||
- (void) setAuxiliaryMailAccounts: (NSArray *) newAccounts
|
||||
{
|
||||
[self setObject: newAccounts forKey: @"AuxiliaryMailAccounts"];
|
||||
|
||||
Reference in New Issue
Block a user