Change key for envelope addresses metadata

This commit is contained in:
Francis Lachapelle
2014-12-11 09:15:33 -05:00
parent a02026b71b
commit fdf875fb73
2 changed files with 30 additions and 13 deletions
+1 -1
View File
@@ -89,7 +89,7 @@ static Class StrClass = Nil;
meta = [NSMutableDictionary dictionary]; meta = [NSMutableDictionary dictionary];
s = [_address baseEMail]; s = [_address baseEMail];
if (s) [meta setObject: s forKey: @"address"]; if (s) [meta setObject: s forKey: @"email"];
s = [_address personalName]; s = [_address personalName];
if (s) [meta setObject: s forKey: @"name"]; if (s) [meta setObject: s forKey: @"name"];
@@ -18,6 +18,7 @@
//console.debug(JSON.stringify(futureMessageData, undefined, 2)); //console.debug(JSON.stringify(futureMessageData, undefined, 2));
angular.extend(this, futureMessageData); angular.extend(this, futureMessageData);
this.id = this.$absolutePath(); this.id = this.$absolutePath();
this.$formatFullAddresses();
} }
else { else {
// The promise will be unwrapped first // The promise will be unwrapped first
@@ -52,18 +53,42 @@
* @desc Build the path of the message * @desc Build the path of the message
* @returns a string representing the path relative to the mail module * @returns a string representing the path relative to the mail module
*/ */
Message.prototype.$absolutePath = function() { Message.prototype.$absolutePath = function(options) {
var path; var path;
path = _.map(this.mailboxPath.split('/'), function(component) { path = _.map(this.mailboxPath.split('/'), function(component) {
return 'folder' + component.asCSSIdentifier(); return 'folder' + component.asCSSIdentifier();
}); });
path.splice(0, 0, this.accountId); // insert account ID path.splice(0, 0, this.accountId); // insert account ID
path.push(this.uid); // add message UID if (options && options.asDraft && this.draftId) {
path.push(this.draftId); // add draft ID
}
else {
path.push(this.uid); // add message UID
}
return path.join('/'); return path.join('/');
}; };
/**
* @function $formatFullAddresses
* @memberof Message.prototype
* @desc Preformat all sender and recipients addresses with a complete description (name <email>).
*/
Message.prototype.$formatFullAddresses = function() {
var _this = this;
// Build long representation of email addresses
_.each(['from', 'to', 'cc', 'bcc', 'reply-to'], function(type) {
_.each(_this[type], function(data, i) {
if (data.name && data.name != data.email)
data.full = data.name + ' <' + data.email + '>';
else
data.full = '<' + data.email + '>';
});
});
};
/** /**
* @function $shortAddress * @function $shortAddress
* @memberof Message.prototype * @memberof Message.prototype
@@ -116,16 +141,8 @@
Message.$timeout(function() { Message.$timeout(function() {
angular.extend(_this, data); angular.extend(_this, data);
_this.id = _this.$absolutePath(); _this.id = _this.$absolutePath();
// Build long representation of email addresses _this.$formatFullAddresses();
_.each(['from', 'to', 'cc', 'bcc', 'reply-to'], function(type) { deferred.resolve(_this);
_.each(_this[type], function(data, i) {
if (data.name && data.name != data.address)
data.full = data.name + ' <' + data.address + '>';
else
data.full = '<' + data.address + '>';
});
});
deferred.resolve(_this.content);
}); });
}, function(data) { }, function(data) {
angular.extend(_this, data); angular.extend(_this, data);