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.pull/293/head
parent
2826c83fc5
commit
fc4f5d2161
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2007-2020 Inverse inc.
|
Copyright (C) 2007-2021 Inverse inc.
|
||||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||||
|
|
||||||
This file is part of SOGo.
|
This file is part of SOGo.
|
||||||
|
@ -685,37 +685,40 @@ static NSString *userAgent = nil;
|
||||||
NSDictionary *identity;
|
NSDictionary *identity;
|
||||||
NSMutableArray *addrs;
|
NSMutableArray *addrs;
|
||||||
NSString *email;
|
NSString *email;
|
||||||
|
SOGoMailAccount *account;
|
||||||
int i;
|
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;
|
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];
|
[self _addRecipients: [_envelope to] toArray: addrs];
|
||||||
identity = [[[self container] mailAccountFolder] identityForEmail: email];
|
[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)
|
if (!identity)
|
||||||
{
|
{
|
||||||
identity = [[context activeUser] defaultIdentity];
|
identity = [account defaultIdentity];
|
||||||
if (identity)
|
if (identity)
|
||||||
[_info setObject: [self _emailFromIdentity: identity] forKey: @"from"];
|
[_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.
|
This file is part of SOGo.
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ typedef enum {
|
||||||
|
|
||||||
- (NSArray *) identities;
|
- (NSArray *) identities;
|
||||||
- (NSDictionary *) defaultIdentity;
|
- (NSDictionary *) defaultIdentity;
|
||||||
|
- (BOOL) forceDefaultIdentity;
|
||||||
- (NSDictionary *) identityForEmail: (NSString *) email;
|
- (NSDictionary *) identityForEmail: (NSString *) email;
|
||||||
- (NSString *) signature;
|
- (NSString *) signature;
|
||||||
- (NSString *) encryption;
|
- (NSString *) encryption;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2007-2020 Inverse inc.
|
Copyright (C) 2007-2021 Inverse inc.
|
||||||
|
|
||||||
This file is part of SOGo.
|
This file is part of SOGo.
|
||||||
|
|
||||||
|
@ -694,6 +694,11 @@ static NSString *inboxFolderName = @"INBOX";
|
||||||
return defaultIdentity; // can be nil
|
return defaultIdentity; // can be nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) forceDefaultIdentity
|
||||||
|
{
|
||||||
|
return [[[self _mailAccount] objectForKey: @"forceDefaultIdentity"] boolValue];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSDictionary *) identityForEmail: (NSString *) email
|
- (NSDictionary *) identityForEmail: (NSString *) email
|
||||||
{
|
{
|
||||||
NSDictionary *identity, *currentIdentity;
|
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.
|
This file is part of SOGo.
|
||||||
|
|
||||||
|
@ -884,6 +884,9 @@
|
||||||
[mailAccount setObject: identities forKey: @"identities"];
|
[mailAccount setObject: identities forKey: @"identities"];
|
||||||
[identities release];
|
[identities release];
|
||||||
|
|
||||||
|
if ([_defaults mailForceDefaultIdentity])
|
||||||
|
[mailAccount setObject: [NSNumber numberWithBool: YES] forKey: @"forceDefaultIdentity"];
|
||||||
|
|
||||||
// 6. Receipts
|
// 6. Receipts
|
||||||
if ([_defaults allowUserReceipt])
|
if ([_defaults allowUserReceipt])
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* SOGoUserDefaults.h - this file is part of SOGo
|
/* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -185,6 +185,9 @@ extern NSString *SOGoWeekStartFirstFullWeek;
|
||||||
- (void) setMailIdentities: (NSArray *) newIdentites;
|
- (void) setMailIdentities: (NSArray *) newIdentites;
|
||||||
- (NSArray *) mailIdentities;
|
- (NSArray *) mailIdentities;
|
||||||
|
|
||||||
|
- (void) setMailForceDefaultIdentity: (BOOL) newValue;
|
||||||
|
- (BOOL) mailForceDefaultIdentity;
|
||||||
|
|
||||||
- (void) setAuxiliaryMailAccounts: (NSArray *) newAccounts;
|
- (void) setAuxiliaryMailAccounts: (NSArray *) newAccounts;
|
||||||
- (NSArray *) auxiliaryMailAccounts;
|
- (NSArray *) auxiliaryMailAccounts;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* SOGoUserDefaults.m - this file is part of SOGo
|
/* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -768,6 +768,16 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
|
||||||
return [self arrayForKey: @"SOGoMailIdentities"];
|
return [self arrayForKey: @"SOGoMailIdentities"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setMailForceDefaultIdentity: (BOOL) newValue
|
||||||
|
{
|
||||||
|
[self setBool: newValue forKey: @"SOGoMailForceDefaultIdentity"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) mailForceDefaultIdentity
|
||||||
|
{
|
||||||
|
return [self boolForKey: @"SOGoMailForceDefaultIdentity"];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) setAuxiliaryMailAccounts: (NSArray *) newAccounts
|
- (void) setAuxiliaryMailAccounts: (NSArray *) newAccounts
|
||||||
{
|
{
|
||||||
[self setObject: newAccounts forKey: @"AuxiliaryMailAccounts"];
|
[self setObject: newAccounts forKey: @"AuxiliaryMailAccounts"];
|
||||||
|
|
|
@ -215,6 +215,7 @@
|
||||||
"Reply To Email" = "Reply To Email";
|
"Reply To Email" = "Reply To Email";
|
||||||
"Signature" = "Signature";
|
"Signature" = "Signature";
|
||||||
"Identities" = "Identities";
|
"Identities" = "Identities";
|
||||||
|
"Always use the default identity when replying to messages" = "Always use the default identity when replying to messages";
|
||||||
"Default Identity" = "Default Identity";
|
"Default Identity" = "Default Identity";
|
||||||
"New Identity" = "New Identity";
|
"New Identity" = "New Identity";
|
||||||
"(Click to create)" = "(Click to create)";
|
"(Click to create)" = "(Click to create)";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* UIxJSONPreferences.m - this file is part of SOGo
|
/* UIxJSONPreferences.m - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2020 Inverse inc.
|
* Copyright (C) 2007-2021 Inverse inc.
|
||||||
*
|
*
|
||||||
* This file is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -441,6 +441,7 @@ static SoProduct *preferencesProduct = nil;
|
||||||
[values removeObjectForKey: @"SOGoMailCertificate"];
|
[values removeObjectForKey: @"SOGoMailCertificate"];
|
||||||
[values removeObjectForKey: @"SOGoMailCertificateAlwaysSign"];
|
[values removeObjectForKey: @"SOGoMailCertificateAlwaysSign"];
|
||||||
[values removeObjectForKey: @"SOGoMailCertificateAlwaysEncrypt"];
|
[values removeObjectForKey: @"SOGoMailCertificateAlwaysEncrypt"];
|
||||||
|
[values removeObjectForKey: @"SOGoMailForceDefaultIdentity"];
|
||||||
|
|
||||||
// Add the domain's default vacation subject if user has not specified a custom subject
|
// Add the domain's default vacation subject if user has not specified a custom subject
|
||||||
vacationOptions = [defaults vacationOptions];
|
vacationOptions = [defaults vacationOptions];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* UIxPreferences.m - this file is part of SOGo
|
/* UIxPreferences.m - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2020 Inverse inc.
|
* Copyright (C) 2007-2021 Inverse inc.
|
||||||
*
|
*
|
||||||
* This file is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -1253,7 +1253,7 @@ static NSArray *reminderValues = nil;
|
||||||
{
|
{
|
||||||
knownKeys = [NSArray arrayWithObjects: @"id", @"name", @"serverName", @"port",
|
knownKeys = [NSArray arrayWithObjects: @"id", @"name", @"serverName", @"port",
|
||||||
@"userName", @"password", @"encryption", @"replyTo",
|
@"userName", @"password", @"encryption", @"replyTo",
|
||||||
@"identities", @"mailboxes",
|
@"identities", @"mailboxes", @"forceDefaultIdentity",
|
||||||
@"receipts", @"security", @"isNew",
|
@"receipts", @"security", @"isNew",
|
||||||
nil];
|
nil];
|
||||||
[knownKeys retain];
|
[knownKeys retain];
|
||||||
|
@ -1307,6 +1307,10 @@ static NSArray *reminderValues = nil;
|
||||||
identities = [account objectForKey: @"identities"];
|
identities = [account objectForKey: @"identities"];
|
||||||
if ([self _validateAccountIdentities: identities])
|
if ([self _validateAccountIdentities: identities])
|
||||||
[target setObject: identities forKey: @"SOGoMailIdentities"];
|
[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"];
|
||||||
[self _extractMainReceiptsPreferences: [account objectForKey: @"receipts"] inDictionary: target];
|
[self _extractMainReceiptsPreferences: [account objectForKey: @"receipts"] inDictionary: target];
|
||||||
[self _extractMainSecurityPreferences: [account objectForKey: @"security"] inDictionary: target];
|
[self _extractMainSecurityPreferences: [account objectForKey: @"security"] inDictionary: target];
|
||||||
}
|
}
|
||||||
|
@ -1512,6 +1516,7 @@ static NSArray *reminderValues = nil;
|
||||||
if ([accounts count] > 0)
|
if ([accounts count] > 0)
|
||||||
{
|
{
|
||||||
// The first account is the main system account. The following mapping is required:
|
// The first account is the main system account. The following mapping is required:
|
||||||
|
// - forceDefaultIdentity => SOGoMailForceDefaultIdentity
|
||||||
// - receipts.receiptAction => SOGoMailReceiptAllow
|
// - receipts.receiptAction => SOGoMailReceiptAllow
|
||||||
// - receipts.receiptNonRecipientAction => SOGoMailReceiptNonRecipientAction
|
// - receipts.receiptNonRecipientAction => SOGoMailReceiptNonRecipientAction
|
||||||
// - receipts.receiptOutsideDomainAction => SOGoMailReceiptOutsideDomainAction
|
// - receipts.receiptOutsideDomainAction => SOGoMailReceiptOutsideDomainAction
|
||||||
|
|
|
@ -97,6 +97,12 @@
|
||||||
<!-- identities -->
|
<!-- identities -->
|
||||||
<div class="pseudo-input-container" ng-if="$AccountDialogController.hasIdentities()">
|
<div class="pseudo-input-container" ng-if="$AccountDialogController.hasIdentities()">
|
||||||
<label class="pseudo-input-label"><var:string label:value="Identities"/></label>
|
<label class="pseudo-input-label"><var:string label:value="Identities"/></label>
|
||||||
|
<md-checkbox
|
||||||
|
class="pseudo-input-field"
|
||||||
|
ng-show="$AccountDialogController.hasDefaultIdentity()"
|
||||||
|
ng-model="$AccountDialogController.account.forceDefaultIdentity"
|
||||||
|
ng-true-value="1"
|
||||||
|
ng-false-value="0"><var:string label:value="Always use the default identity when replying to messages"/></md-checkbox>
|
||||||
<md-card ng-repeat="identity in $AccountDialogController.account.identities | filter:$AccountDialogController.isEditableIdentity"
|
<md-card ng-repeat="identity in $AccountDialogController.account.identities | filter:$AccountDialogController.isEditableIdentity"
|
||||||
class="sg-collapsed"
|
class="sg-collapsed"
|
||||||
ng-class="{ 'sg-expanded': $index == $AccountDialogController.selectedIdentity }">
|
ng-class="{ 'sg-expanded': $index == $AccountDialogController.selectedIdentity }">
|
||||||
|
|
|
@ -480,7 +480,7 @@
|
||||||
* @return an object literal copy of the Account instance
|
* @return an object literal copy of the Account instance
|
||||||
*/
|
*/
|
||||||
Account.prototype.$omit = function () {
|
Account.prototype.$omit = function () {
|
||||||
var account = {}, identities = [];
|
var account = {}, identities = [], defaultIdentity = false;
|
||||||
|
|
||||||
angular.forEach(this, function(value, key) {
|
angular.forEach(this, function(value, key) {
|
||||||
if (key != 'constructor' && key !='identities' && key[0] != '$') {
|
if (key != 'constructor' && key !='identities' && key[0] != '$') {
|
||||||
|
@ -491,9 +491,14 @@
|
||||||
_.forEach(this.identities, function (identity) {
|
_.forEach(this.identities, function (identity) {
|
||||||
if (!identity.isReadOnly)
|
if (!identity.isReadOnly)
|
||||||
identities.push(_.pick(identity, ['email', 'fullName', 'replyTo', 'signature', 'isDefault']));
|
identities.push(_.pick(identity, ['email', 'fullName', 'replyTo', 'signature', 'isDefault']));
|
||||||
|
if (identity.isDefault)
|
||||||
|
defaultIdentity = identity;
|
||||||
});
|
});
|
||||||
account.identities = identities;
|
account.identities = identities;
|
||||||
|
|
||||||
|
if (!defaultIdentity || !account.forceDefaultIdentity)
|
||||||
|
delete account.forceDefaultIdentity;
|
||||||
|
|
||||||
return account;
|
return account;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,10 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.hasDefaultIdentity = function() {
|
||||||
|
return _.findIndex(this.account.identities, function(identity) { return !!identity.isDefault; }) >= 0;
|
||||||
|
};
|
||||||
|
|
||||||
this.setDefaultIdentity = function ($event, $index) {
|
this.setDefaultIdentity = function ($event, $index) {
|
||||||
_.forEach(this.account.identities, function(identity, i) {
|
_.forEach(this.account.identities, function(identity, i) {
|
||||||
if (i == $index)
|
if (i == $index)
|
||||||
|
|
Loading…
Reference in New Issue