Fix sender addresses of draft
The sender addresses select menu is now populated with the identities of the selected account *only*. The chosen sender address is also restored from the draft. Fixes #3577pull/207/head
parent
7d5255f762
commit
a1e0f2767f
1
NEWS
1
NEWS
|
@ -50,6 +50,7 @@ Bug fixes
|
|||
- [web] retired CSS reset so the style of HTML messages is respected (#3582)
|
||||
- [web] fixed messages archiving as zip file
|
||||
- [web] adapted time picker to match changes of md calendar picker
|
||||
- [web] fixed sender addresses of draft when using multiple IMAP accounts (#3577)
|
||||
- [dav] we now handle the default classifications for tasks (#3541)
|
||||
- [eas] properly unfold long mail headers (#3152)
|
||||
- [eas] correctly set EAS message class for S/MIME messages (#3576)
|
||||
|
|
|
@ -924,6 +924,10 @@ static NSString *userAgent = nil;
|
|||
[info setObject: msgid forKey: @"message-id"];
|
||||
|
||||
addresses = [NSMutableArray array];
|
||||
[self _addEMailsOfAddresses: [sourceEnvelope from] toArray: addresses];
|
||||
if ([addresses count])
|
||||
[info setObject: [addresses objectAtIndex: 0] forKey: @"from"];
|
||||
addresses = [NSMutableArray array];
|
||||
[self _addEMailsOfAddresses: [sourceEnvelope to] toArray: addresses];
|
||||
[info setObject: addresses forKey: @"to"];
|
||||
addresses = [NSMutableArray array];
|
||||
|
|
|
@ -250,14 +250,17 @@ static NSArray *infoKeys = nil;
|
|||
|
||||
- (NSString *) from
|
||||
{
|
||||
NSDictionary *identity;
|
||||
NSArray *identities;
|
||||
|
||||
if (!from)
|
||||
{
|
||||
identity = [[context activeUser] primaryIdentity];
|
||||
from = [self _emailFromIdentity: identity];
|
||||
identities = [[[self clientObject] mailAccountFolder] identities];
|
||||
if ([identities count])
|
||||
{
|
||||
from = [self _emailFromIdentity: [identities objectAtIndex: 0]];
|
||||
[from retain];
|
||||
}
|
||||
}
|
||||
|
||||
return from;
|
||||
}
|
||||
|
@ -426,7 +429,7 @@ static NSArray *infoKeys = nil;
|
|||
{
|
||||
if (![_info isNotNull]) return;
|
||||
[self debugWithFormat:@"loading info ..."];
|
||||
[self setValuesForKeysWithDictionary:_info];
|
||||
[self setValuesForKeysWithDictionary: _info];
|
||||
}
|
||||
|
||||
- (NSDictionary *) infoFromRequest
|
||||
|
@ -439,6 +442,7 @@ static NSArray *infoKeys = nil;
|
|||
filteredParams = [NSDictionary dictionaryWithObjects: [params objectsForKeys: infoKeys notFoundMarker: [NSNull null]]
|
||||
forKeys: infoKeys];
|
||||
|
||||
[self setFrom: [filteredParams objectForKey: @"from"]];
|
||||
[self setTo: [filteredParams objectForKey: @"to"]];
|
||||
[self setCc: [filteredParams objectForKey: @"cc"]];
|
||||
[self setBcc: [filteredParams objectForKey: @"bcc"]];
|
||||
|
|
|
@ -218,7 +218,7 @@
|
|||
controller: 'MessageEditorController',
|
||||
controllerAs: 'editor',
|
||||
locals: {
|
||||
stateAccounts: vm.accounts,
|
||||
stateAccount: vm.account,
|
||||
stateMessage: message,
|
||||
stateRecipients: []
|
||||
}
|
||||
|
|
|
@ -103,23 +103,26 @@
|
|||
* @returns a string representing the path relative to the mail module
|
||||
*/
|
||||
Message.prototype.$absolutePath = function(options) {
|
||||
if (angular.isUndefined(this.id) || options) {
|
||||
var _this = this, id = this.id;
|
||||
|
||||
function buildPath() {
|
||||
var path;
|
||||
path = _.map(this.$mailbox.path.split('/'), function(component) {
|
||||
path = _.map(_this.$mailbox.path.split('/'), function(component) {
|
||||
return 'folder' + component.asCSSIdentifier();
|
||||
});
|
||||
path.splice(0, 0, this.accountId); // insert account ID
|
||||
path.splice(0, 0, _this.accountId); // insert account ID
|
||||
return path.join('/');
|
||||
}
|
||||
|
||||
if (angular.isUndefined(this.id) || options && options.nocache) {
|
||||
this.id = buildPath() + '/' + this.uid; // add message UID
|
||||
id = this.id;
|
||||
}
|
||||
if (options && options.asDraft && this.draftId) {
|
||||
path.push(this.draftId); // add draft ID
|
||||
}
|
||||
else {
|
||||
path.push(this.uid); // add message UID
|
||||
id = buildPath() + '/' + this.draftId; // add draft ID
|
||||
}
|
||||
|
||||
this.id = path.join('/');
|
||||
}
|
||||
|
||||
return this.id;
|
||||
return id;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -129,15 +132,22 @@
|
|||
* @param {number} uid - the new message UID
|
||||
*/
|
||||
Message.prototype.$setUID = function(uid) {
|
||||
var oldUID = (this.uid || -1);
|
||||
var oldUID = (this.uid || -1), _this = this, index;
|
||||
|
||||
if (oldUID != parseInt(uid)) {
|
||||
this.uid = parseInt(uid);
|
||||
this.$absolutePath({nocache: true});
|
||||
if (oldUID > -1) {
|
||||
oldUID = oldUID.toString();
|
||||
if (angular.isDefined(this.$mailbox.uidsMap[oldUID])) {
|
||||
this.$mailbox.uidsMap[uid] = this.$mailbox.uidsMap[oldUID];
|
||||
index = this.$mailbox.uidsMap[oldUID];
|
||||
this.$mailbox.uidsMap[uid] = index;
|
||||
delete this.$mailbox.uidsMap[oldUID];
|
||||
|
||||
// Update messages list of mailbox
|
||||
_.forEach(['from', 'to', 'subject'], function(attr) {
|
||||
_this.$mailbox.$messages[index][attr] = _this[attr];
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -365,6 +375,12 @@
|
|||
return Message.$$resource.fetch(this.$absolutePath(), 'edit').then(function(data) {
|
||||
angular.extend(_this, data);
|
||||
return Message.$$resource.fetch(_this.$absolutePath({asDraft: true}), 'edit').then(function(data) {
|
||||
// Try to match a known account identity from the specified "from" address
|
||||
var identity = _.find(_this.$mailbox.$account.identities, function(identity) {
|
||||
return data.from.toLowerCase().indexOf(identity.email) !== -1;
|
||||
});
|
||||
if (identity)
|
||||
data.from = identity.full;
|
||||
Message.$log.debug('editable = ' + JSON.stringify(data, undefined, 2));
|
||||
angular.extend(_this.editable, data);
|
||||
return data.text;
|
||||
|
@ -580,7 +596,7 @@
|
|||
return Message.$$resource.save(this.$absolutePath({asDraft: true}), data).then(function(response) {
|
||||
Message.$log.debug('save = ' + JSON.stringify(response, undefined, 2));
|
||||
_this.$setUID(response.uid);
|
||||
_this.$reload({asDraft: false}); // fetch a new viewable version of the message
|
||||
_this.$reload(); // fetch a new viewable version of the message
|
||||
_this.isNew = false;
|
||||
});
|
||||
};
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
MessageEditorController.$inject = ['$window', '$stateParams', '$mdConstant', '$mdDialog', '$mdToast', 'FileUploader', 'stateAccounts', 'stateMessage', 'stateRecipients', 'encodeUriFilter', '$timeout', 'Dialog', 'AddressBook', 'Card', 'Preferences'];
|
||||
function MessageEditorController($window, $stateParams, $mdConstant, $mdDialog, $mdToast, FileUploader, stateAccounts, stateMessage, stateRecipients, encodeUriFilter, $timeout, Dialog, AddressBook, Card, Preferences) {
|
||||
MessageEditorController.$inject = ['$window', '$stateParams', '$mdConstant', '$mdDialog', '$mdToast', 'FileUploader', 'stateAccount', 'stateMessage', 'stateRecipients', 'encodeUriFilter', '$timeout', 'Dialog', 'AddressBook', 'Card', 'Preferences'];
|
||||
function MessageEditorController($window, $stateParams, $mdConstant, $mdDialog, $mdToast, FileUploader, stateAccount, stateMessage, stateRecipients, encodeUriFilter, $timeout, Dialog, AddressBook, Card, Preferences) {
|
||||
var vm = this, semicolon = 186;
|
||||
|
||||
vm.addRecipient = addRecipient;
|
||||
|
@ -21,7 +21,7 @@
|
|||
vm.send = send;
|
||||
vm.removeAttachment = removeAttachment;
|
||||
vm.contactFilter = contactFilter;
|
||||
vm.identities = _.map(_.flatten(_.map(stateAccounts, 'identities')), 'full');
|
||||
vm.identities = _.map(stateAccount.identities, 'full');
|
||||
vm.recipientSeparatorKeys = [$mdConstant.KEY_CODE.ENTER, $mdConstant.KEY_CODE.TAB, $mdConstant.KEY_CODE.COMMA, semicolon];
|
||||
vm.uploader = new FileUploader({
|
||||
url: stateMessage.$absolutePath({asDraft: true}) + '/save',
|
||||
|
|
Loading…
Reference in New Issue