mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-10-06 19:55:49 +08:00
Fixes for scrutinizer-ci
This commit is contained in:
parent
51b9e400d2
commit
c7e97b78d6
3 changed files with 80 additions and 138 deletions
|
@ -320,7 +320,6 @@ MessageUserStore.prototype.removeMessagesFromList = function(
|
||||||
var
|
var
|
||||||
self = this,
|
self = this,
|
||||||
iUnseenCount = 0,
|
iUnseenCount = 0,
|
||||||
oMessage = null,
|
|
||||||
sTrashFolder = FolderStore.trashFolder(),
|
sTrashFolder = FolderStore.trashFolder(),
|
||||||
sSpamFolder = FolderStore.spamFolder(),
|
sSpamFolder = FolderStore.spamFolder(),
|
||||||
aMessageList = this.messageList(),
|
aMessageList = this.messageList(),
|
||||||
|
@ -415,7 +414,7 @@ MessageUserStore.prototype.removeMessagesFromList = function(
|
||||||
return !!(item && item.deleted() && item.uid === self.messageListThreadUid());
|
return !!(item && item.deleted() && item.uid === self.messageListThreadUid());
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
oMessage = _.find(aMessageList, function(item) {
|
var oMessage = _.find(aMessageList, function(item) {
|
||||||
return item && !item.deleted();
|
return item && !item.deleted();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -510,25 +509,19 @@ MessageUserStore.prototype.setMessage = function(oData, bCached)
|
||||||
{
|
{
|
||||||
var
|
var
|
||||||
bNew = false,
|
bNew = false,
|
||||||
bIsHtml = false,
|
|
||||||
bHasExternals = false,
|
|
||||||
bHasInternals = false,
|
|
||||||
oBody = null,
|
oBody = null,
|
||||||
oTextBody = null,
|
|
||||||
sId = '',
|
sId = '',
|
||||||
sPlain = '',
|
sPlain = '',
|
||||||
sResultHtml = '',
|
sResultHtml = '',
|
||||||
bPgpSigned = false,
|
bPgpSigned = false,
|
||||||
bPgpEncrypted = false,
|
|
||||||
oMessagesDom = this.messagesBodiesDom(),
|
oMessagesDom = this.messagesBodiesDom(),
|
||||||
oSelectedMessage = this.selectorMessageSelected(),
|
oSelectedMessage = this.selectorMessageSelected(),
|
||||||
oMessage = this.message(),
|
oMessage = this.message();
|
||||||
aThreads = [];
|
|
||||||
|
|
||||||
if (oData && oMessage && oData.Result && 'Object/Message' === oData.Result['@Object'] &&
|
if (oData && oMessage && oData.Result && 'Object/Message' === oData.Result['@Object'] &&
|
||||||
oMessage.folderFullNameRaw === oData.Result.Folder)
|
oMessage.folderFullNameRaw === oData.Result.Folder)
|
||||||
{
|
{
|
||||||
aThreads = oMessage.threads();
|
var aThreads = oMessage.threads();
|
||||||
if (oMessage.uid !== oData.Result.Uid && 1 < aThreads.length &&
|
if (oMessage.uid !== oData.Result.Uid && 1 < aThreads.length &&
|
||||||
-1 < Utils.inArray(oData.Result.Uid, aThreads))
|
-1 < Utils.inArray(oData.Result.Uid, aThreads))
|
||||||
{
|
{
|
||||||
|
@ -561,13 +554,11 @@ MessageUserStore.prototype.setMessage = function(oData, bCached)
|
||||||
if (oMessagesDom)
|
if (oMessagesDom)
|
||||||
{
|
{
|
||||||
sId = 'rl-mgs-' + oMessage.hash.replace(/[^a-zA-Z0-9]/g, '');
|
sId = 'rl-mgs-' + oMessage.hash.replace(/[^a-zA-Z0-9]/g, '');
|
||||||
oTextBody = oMessagesDom.find('#' + sId);
|
|
||||||
|
|
||||||
|
var oTextBody = oMessagesDom.find('#' + sId);
|
||||||
if (!oTextBody || !oTextBody[0])
|
if (!oTextBody || !oTextBody[0])
|
||||||
{
|
{
|
||||||
bHasExternals = !!oData.Result.HasExternals;
|
var bIsHtml = false;
|
||||||
bHasInternals = !!oData.Result.HasInternals;
|
|
||||||
|
|
||||||
if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html)
|
if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html)
|
||||||
{
|
{
|
||||||
bIsHtml = true;
|
bIsHtml = true;
|
||||||
|
@ -582,7 +573,7 @@ MessageUserStore.prototype.setMessage = function(oData, bCached)
|
||||||
{
|
{
|
||||||
sPlain = Utils.pString(oData.Result.Plain);
|
sPlain = Utils.pString(oData.Result.Plain);
|
||||||
|
|
||||||
bPgpEncrypted = (/---BEGIN PGP MESSAGE---/).test(sPlain);
|
var bPgpEncrypted = (/---BEGIN PGP MESSAGE---/).test(sPlain);
|
||||||
if (!bPgpEncrypted)
|
if (!bPgpEncrypted)
|
||||||
{
|
{
|
||||||
bPgpSigned = (/-----BEGIN PGP SIGNED MESSAGE-----/).test(sPlain) &&
|
bPgpSigned = (/-----BEGIN PGP SIGNED MESSAGE-----/).test(sPlain) &&
|
||||||
|
@ -609,8 +600,6 @@ MessageUserStore.prototype.setMessage = function(oData, bCached)
|
||||||
sResultHtml = '<pre>' + sResultHtml + '</pre>';
|
sResultHtml = '<pre>' + sResultHtml + '</pre>';
|
||||||
}
|
}
|
||||||
|
|
||||||
sPlain = '';
|
|
||||||
|
|
||||||
Globals.$div.empty();
|
Globals.$div.empty();
|
||||||
|
|
||||||
oMessage.isPgpSigned(bPgpSigned);
|
oMessage.isPgpSigned(bPgpSigned);
|
||||||
|
@ -637,7 +626,7 @@ MessageUserStore.prototype.setMessage = function(oData, bCached)
|
||||||
.addClass('b-text-part ' + (bIsHtml ? 'html' : 'plain'));
|
.addClass('b-text-part ' + (bIsHtml ? 'html' : 'plain'));
|
||||||
|
|
||||||
oMessage.isHtml(!!bIsHtml);
|
oMessage.isHtml(!!bIsHtml);
|
||||||
oMessage.hasImages(!!bHasExternals);
|
oMessage.hasImages(!!oData.Result.HasExternals);
|
||||||
|
|
||||||
oMessage.body = oBody;
|
oMessage.body = oBody;
|
||||||
if (oMessage.body)
|
if (oMessage.body)
|
||||||
|
@ -647,7 +636,7 @@ MessageUserStore.prototype.setMessage = function(oData, bCached)
|
||||||
|
|
||||||
oMessage.storeDataInDom();
|
oMessage.storeDataInDom();
|
||||||
|
|
||||||
if (bHasInternals)
|
if (oData.Result.HasInternals)
|
||||||
{
|
{
|
||||||
oMessage.showInternalImages(true);
|
oMessage.showInternalImages(true);
|
||||||
}
|
}
|
||||||
|
@ -815,14 +804,9 @@ MessageUserStore.prototype.setMessageList = function(oData, bCached)
|
||||||
oData.Result['@Collection'] && Utils.isArray(oData.Result['@Collection']))
|
oData.Result['@Collection'] && Utils.isArray(oData.Result['@Collection']))
|
||||||
{
|
{
|
||||||
var
|
var
|
||||||
iIndex = 0,
|
|
||||||
iLen = 0,
|
|
||||||
iCount = 0,
|
iCount = 0,
|
||||||
iOffset = 0,
|
iOffset = 0,
|
||||||
aList = [],
|
aList = [],
|
||||||
oJsonMessage = null,
|
|
||||||
oMessage = null,
|
|
||||||
oFolder = null,
|
|
||||||
iNewCount = 0,
|
iNewCount = 0,
|
||||||
iUtc = require('Common/Momentor').momentNowUnix(),
|
iUtc = require('Common/Momentor').momentNowUnix(),
|
||||||
bUnreadCountChange = false;
|
bUnreadCountChange = false;
|
||||||
|
@ -830,9 +814,7 @@ MessageUserStore.prototype.setMessageList = function(oData, bCached)
|
||||||
iCount = Utils.pInt(oData.Result.MessageResultCount);
|
iCount = Utils.pInt(oData.Result.MessageResultCount);
|
||||||
iOffset = Utils.pInt(oData.Result.Offset);
|
iOffset = Utils.pInt(oData.Result.Offset);
|
||||||
|
|
||||||
oFolder = Cache.getFolderFromCacheList(
|
var oFolder = Cache.getFolderFromCacheList(Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : '');
|
||||||
Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : '');
|
|
||||||
|
|
||||||
if (oFolder && !bCached)
|
if (oFolder && !bCached)
|
||||||
{
|
{
|
||||||
oFolder.interval = iUtc;
|
oFolder.interval = iUtc;
|
||||||
|
@ -862,12 +844,10 @@ MessageUserStore.prototype.setMessageList = function(oData, bCached)
|
||||||
Cache.clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw);
|
Cache.clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (iIndex = 0, iLen = oData.Result['@Collection'].length; iIndex < iLen; iIndex++)
|
_.each(oData.Result['@Collection'], function(oJsonMessage) {
|
||||||
{
|
|
||||||
oJsonMessage = oData.Result['@Collection'][iIndex];
|
|
||||||
if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object'])
|
if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object'])
|
||||||
{
|
{
|
||||||
oMessage = MessageModel.newInstanceFromJson(oJsonMessage);
|
var oMessage = MessageModel.newInstanceFromJson(oJsonMessage);
|
||||||
if (oMessage)
|
if (oMessage)
|
||||||
{
|
{
|
||||||
if (Cache.hasNewMessageAndRemoveFromCache(oMessage.folderFullNameRaw, oMessage.uid) && 5 >= iNewCount)
|
if (Cache.hasNewMessageAndRemoveFromCache(oMessage.folderFullNameRaw, oMessage.uid) && 5 >= iNewCount)
|
||||||
|
@ -890,7 +870,7 @@ MessageUserStore.prototype.setMessageList = function(oData, bCached)
|
||||||
aList.push(oMessage);
|
aList.push(oMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
this.messageListCount(iCount);
|
this.messageListCount(iCount);
|
||||||
this.messageListSearch(Utils.isNormal(oData.Result.Search) ? oData.Result.Search : '');
|
this.messageListSearch(Utils.isNormal(oData.Result.Search) ? oData.Result.Search : '');
|
||||||
|
|
|
@ -77,8 +77,6 @@ PgpUserStore.prototype.findPrivateKeysByEncryptionKeyIds = function(aEncryptionK
|
||||||
{
|
{
|
||||||
var
|
var
|
||||||
self = this,
|
self = this,
|
||||||
aResult = [];
|
|
||||||
|
|
||||||
aResult = Utils.isArray(aEncryptionKeyIds) ? _.compact(_.flatten(_.map(aEncryptionKeyIds, function(oId) {
|
aResult = Utils.isArray(aEncryptionKeyIds) ? _.compact(_.flatten(_.map(aEncryptionKeyIds, function(oId) {
|
||||||
var oKey = oId && oId.toHex ? self.findPrivateKeyByHex(oId.toHex()) : null;
|
var oKey = oId && oId.toHex ? self.findPrivateKeyByHex(oId.toHex()) : null;
|
||||||
return oKey ? (bReturnWrapKeys ? [oKey] : oKey.getNativeKeys()) : [null];
|
return oKey ? (bReturnWrapKeys ? [oKey] : oKey.getNativeKeys()) : [null];
|
||||||
|
@ -149,7 +147,6 @@ PgpUserStore.prototype.findAllPrivateKeysByEmailNotNative = function(sEmail)
|
||||||
PgpUserStore.prototype.findPrivateKeyByEmail = function(sEmail, sPassword)
|
PgpUserStore.prototype.findPrivateKeyByEmail = function(sEmail, sPassword)
|
||||||
{
|
{
|
||||||
var
|
var
|
||||||
oPrivateKeys = [],
|
|
||||||
oPrivateKey = null,
|
oPrivateKey = null,
|
||||||
oKey = _.find(this.openpgpkeysPrivate(), function(oItem) {
|
oKey = _.find(this.openpgpkeysPrivate(), function(oItem) {
|
||||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||||
|
@ -157,11 +154,9 @@ PgpUserStore.prototype.findPrivateKeyByEmail = function(sEmail, sPassword)
|
||||||
|
|
||||||
if (oKey)
|
if (oKey)
|
||||||
{
|
{
|
||||||
oPrivateKeys = oKey.getNativeKeys();
|
|
||||||
oPrivateKey = oPrivateKeys[0] || null;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
oPrivateKey = oKey.getNativeKeys()[0] || null;
|
||||||
if (oPrivateKey)
|
if (oPrivateKey)
|
||||||
{
|
{
|
||||||
oPrivateKey.decrypt(Utils.pString(sPassword));
|
oPrivateKey.decrypt(Utils.pString(sPassword));
|
||||||
|
@ -187,13 +182,11 @@ PgpUserStore.prototype.findSelfPrivateKey = function(sPassword)
|
||||||
|
|
||||||
PgpUserStore.prototype.decryptMessage = function(oMessage, aRecipients, fCallback)
|
PgpUserStore.prototype.decryptMessage = function(oMessage, aRecipients, fCallback)
|
||||||
{
|
{
|
||||||
var
|
|
||||||
self = this,
|
|
||||||
aPrivateKeys = [];
|
|
||||||
|
|
||||||
if (oMessage && oMessage.getEncryptionKeyIds)
|
if (oMessage && oMessage.getEncryptionKeyIds)
|
||||||
{
|
{
|
||||||
|
var self = this,
|
||||||
aPrivateKeys = this.findPrivateKeysByEncryptionKeyIds(oMessage.getEncryptionKeyIds(), aRecipients, true);
|
aPrivateKeys = this.findPrivateKeysByEncryptionKeyIds(oMessage.getEncryptionKeyIds(), aRecipients, true);
|
||||||
|
|
||||||
if (aPrivateKeys && 0 < aPrivateKeys.length)
|
if (aPrivateKeys && 0 < aPrivateKeys.length)
|
||||||
{
|
{
|
||||||
kn.showScreenPopup(require('View/Popup/MessageOpenPgp'), [function(oDecryptedKey) {
|
kn.showScreenPopup(require('View/Popup/MessageOpenPgp'), [function(oDecryptedKey) {
|
||||||
|
@ -260,27 +253,19 @@ PgpUserStore.prototype.findKeyExternal = function(sEmail, fCallback)
|
||||||
|
|
||||||
PgpUserStore.prototype.verifyMessage = function(oMessage, fCallback)
|
PgpUserStore.prototype.verifyMessage = function(oMessage, fCallback)
|
||||||
{
|
{
|
||||||
var
|
|
||||||
aResult = [],
|
|
||||||
aPublicKeys = [],
|
|
||||||
aSigningKeyIds = [];
|
|
||||||
|
|
||||||
if (oMessage && oMessage.getSigningKeyIds)
|
if (oMessage && oMessage.getSigningKeyIds)
|
||||||
{
|
{
|
||||||
aSigningKeyIds = oMessage.getSigningKeyIds();
|
var aSigningKeyIds = oMessage.getSigningKeyIds();
|
||||||
if (aSigningKeyIds && 0 < aSigningKeyIds.length)
|
if (aSigningKeyIds && 0 < aSigningKeyIds.length)
|
||||||
{
|
{
|
||||||
// this.findKeyExternal('support@rainloop.net', function(key) {
|
var aPublicKeys = this.findPublicKeysBySigningKeyIds(aSigningKeyIds);
|
||||||
// console.log(key);
|
|
||||||
// });
|
|
||||||
|
|
||||||
aPublicKeys = this.findPublicKeysBySigningKeyIds(aSigningKeyIds);
|
|
||||||
if (aPublicKeys && 0 < aPublicKeys.length)
|
if (aPublicKeys && 0 < aPublicKeys.length)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
aResult = oMessage.verify(aPublicKeys);
|
var
|
||||||
var oValid = _.find(_.isArray(aResult) ? aResult : [], function(oItem) {
|
aResult = oMessage.verify(aPublicKeys),
|
||||||
|
oValid = _.find(_.isArray(aResult) ? aResult : [], function(oItem) {
|
||||||
return oItem && oItem.valid && oItem.keyid;
|
return oItem && oItem.valid && oItem.keyid;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -333,8 +318,9 @@ PgpUserStore.prototype.controlsHelper = function(mDom, oVerControl, bSuccess, sT
|
||||||
PgpUserStore.domControlEncryptedClickHelper = function(store, mDom, sArmoredMessage, aRecipients)
|
PgpUserStore.domControlEncryptedClickHelper = function(store, mDom, sArmoredMessage, aRecipients)
|
||||||
{
|
{
|
||||||
return function() {
|
return function() {
|
||||||
|
|
||||||
var
|
var
|
||||||
oMessage = null,
|
message = null,
|
||||||
$this = $(this);
|
$this = $(this);
|
||||||
|
|
||||||
if ($this.hasClass('success'))
|
if ($this.hasClass('success'))
|
||||||
|
@ -344,16 +330,16 @@ PgpUserStore.domControlEncryptedClickHelper = function(store, mDom, sArmoredMess
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
oMessage = store.openpgp.message.readArmored(sArmoredMessage);
|
message = store.openpgp.message.readArmored(sArmoredMessage);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
Utils.log(e);
|
Utils.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oMessage && oMessage.getText && oMessage.verify && oMessage.decrypt)
|
if (message && message.getText && message.verify && message.decrypt)
|
||||||
{
|
{
|
||||||
store.decryptMessage(oMessage, aRecipients, function(oValidPrivateKey, oDecryptedMessage, oValidPublicKey, aSigningKeyIds) {
|
store.decryptMessage(message, aRecipients, function(oValidPrivateKey, oDecryptedMessage, oValidPublicKey, aSigningKeyIds) {
|
||||||
|
|
||||||
if (oDecryptedMessage)
|
if (oDecryptedMessage)
|
||||||
{
|
{
|
||||||
|
@ -405,7 +391,7 @@ PgpUserStore.domControlSignedClickHelper = function(store, mDom, sArmoredMessage
|
||||||
return function() {
|
return function() {
|
||||||
|
|
||||||
var
|
var
|
||||||
oMessage = null,
|
message = null,
|
||||||
$this = $(this);
|
$this = $(this);
|
||||||
|
|
||||||
if ($this.hasClass('success') || $this.hasClass('error'))
|
if ($this.hasClass('success') || $this.hasClass('error'))
|
||||||
|
@ -415,21 +401,21 @@ PgpUserStore.domControlSignedClickHelper = function(store, mDom, sArmoredMessage
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
oMessage = store.openpgp.cleartext.readArmored(sArmoredMessage);
|
message = store.openpgp.cleartext.readArmored(sArmoredMessage);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
Utils.log(e);
|
Utils.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oMessage && oMessage.getText && oMessage.verify)
|
if (message && message.getText && message.verify)
|
||||||
{
|
{
|
||||||
store.verifyMessage(oMessage, function(oValidKey, aSigningKeyIds) {
|
store.verifyMessage(message, function(oValidKey, aSigningKeyIds) {
|
||||||
if (oValidKey)
|
if (oValidKey)
|
||||||
{
|
{
|
||||||
store.controlsHelper(mDom, $this, true, Translator.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
store.controlsHelper(mDom, $this, true, Translator.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||||
'USER': oValidKey.user + ' (' + oValidKey.id + ')'
|
'USER': oValidKey.user + ' (' + oValidKey.id + ')'
|
||||||
}), oMessage.getText());
|
}), message.getText());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -994,21 +994,18 @@ ComposePopupView.prototype.onShow = function(sType, oMessageOrArray,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Function} fKoValue
|
* @param {Function} fKoValue
|
||||||
* @param {Array} aEmails
|
* @param {Array} emails
|
||||||
*/
|
*/
|
||||||
ComposePopupView.prototype.addEmailsTo = function(fKoValue, aEmails)
|
ComposePopupView.prototype.addEmailsTo = function(fKoValue, emails)
|
||||||
{
|
{
|
||||||
var
|
var value = Utils.trim(fKoValue());
|
||||||
sValue = Utils.trim(fKoValue()),
|
if (Utils.isNonEmptyArray(emails))
|
||||||
aValue = [];
|
|
||||||
|
|
||||||
if (Utils.isNonEmptyArray(aEmails))
|
|
||||||
{
|
{
|
||||||
aValue = _.uniq(_.compact(_.map(aEmails, function(oItem) {
|
var values = _.uniq(_.compact(_.map(emails, function(oItem) {
|
||||||
return oItem ? oItem.toLine(false) : null;
|
return oItem ? oItem.toLine(false) : null;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
fKoValue(sValue + ('' === sValue ? '' : ', ') + Utils.trim(aValue.join(', ')));
|
fKoValue(value + ('' === value ? '' : ', ') + Utils.trim(values.join(', ')));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1020,15 +1017,10 @@ ComposePopupView.prototype.addEmailsTo = function(fKoValue, aEmails)
|
||||||
*/
|
*/
|
||||||
ComposePopupView.prototype.emailArrayToStringLineHelper = function(aList, bFriendly)
|
ComposePopupView.prototype.emailArrayToStringLineHelper = function(aList, bFriendly)
|
||||||
{
|
{
|
||||||
var
|
bFriendly = !!bFriendly;
|
||||||
iIndex = 0,
|
var aResult = _.map(aList, function(item) {
|
||||||
iLen = aList.length,
|
return item.toLine(bFriendly);
|
||||||
aResult = [];
|
});
|
||||||
|
|
||||||
for (; iIndex < iLen; iIndex++)
|
|
||||||
{
|
|
||||||
aResult.push(aList[iIndex].toLine(!!bFriendly));
|
|
||||||
}
|
|
||||||
|
|
||||||
return aResult.join(', ');
|
return aResult.join(', ');
|
||||||
};
|
};
|
||||||
|
@ -1775,12 +1767,9 @@ ComposePopupView.prototype.initUploader = function()
|
||||||
|
|
||||||
var
|
var
|
||||||
sError = '',
|
sError = '',
|
||||||
mErrorCode = null,
|
oAttachment = this.getAttachmentById(sId),
|
||||||
oAttachmentJson = null,
|
mErrorCode = oData && oData.Result && oData.Result.ErrorCode ? oData.Result.ErrorCode : null,
|
||||||
oAttachment = this.getAttachmentById(sId);
|
|
||||||
|
|
||||||
oAttachmentJson = bResult && oData && oData.Result && oData.Result.Attachment ? oData.Result.Attachment : null;
|
oAttachmentJson = bResult && oData && oData.Result && oData.Result.Attachment ? oData.Result.Attachment : null;
|
||||||
mErrorCode = oData && oData.Result && oData.Result.ErrorCode ? oData.Result.ErrorCode : null;
|
|
||||||
|
|
||||||
if (null !== mErrorCode)
|
if (null !== mErrorCode)
|
||||||
{
|
{
|
||||||
|
@ -1877,6 +1866,27 @@ ComposePopupView.prototype.addMessageAsAttachment = function(oMessage)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} url
|
||||||
|
* @param {string} name
|
||||||
|
* @param {number} size
|
||||||
|
* @returns {ComposeAttachmentModel}
|
||||||
|
*/
|
||||||
|
ComposePopupView.prototype.addAttachmentHelper = function(url, name, size)
|
||||||
|
{
|
||||||
|
var oAttachment = new ComposeAttachmentModel(url, name, size);
|
||||||
|
|
||||||
|
oAttachment.fromMessage = false;
|
||||||
|
oAttachment.cancel = this.cancelAttachmentHelper(url);
|
||||||
|
oAttachment.waiting(false).uploading(true).complete(false);
|
||||||
|
|
||||||
|
this.attachments.push(oAttachment);
|
||||||
|
|
||||||
|
this.attachmentsPlace(true);
|
||||||
|
|
||||||
|
return oAttachment;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} oDropboxFile
|
* @param {Object} oDropboxFile
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
|
@ -1884,21 +1894,9 @@ ComposePopupView.prototype.addMessageAsAttachment = function(oMessage)
|
||||||
ComposePopupView.prototype.addDropboxAttachment = function(oDropboxFile)
|
ComposePopupView.prototype.addDropboxAttachment = function(oDropboxFile)
|
||||||
{
|
{
|
||||||
var
|
var
|
||||||
oAttachment = null,
|
|
||||||
iAttachmentSizeLimit = Utils.pInt(Settings.settingsGet('AttachmentLimit')),
|
iAttachmentSizeLimit = Utils.pInt(Settings.settingsGet('AttachmentLimit')),
|
||||||
mSize = oDropboxFile.bytes;
|
mSize = oDropboxFile.bytes,
|
||||||
|
oAttachment = this.addAttachmentHelper(oDropboxFile.link, oDropboxFile.name, mSize);
|
||||||
oAttachment = new ComposeAttachmentModel(
|
|
||||||
oDropboxFile.link, oDropboxFile.name, mSize
|
|
||||||
);
|
|
||||||
|
|
||||||
oAttachment.fromMessage = false;
|
|
||||||
oAttachment.cancel = this.cancelAttachmentHelper(oDropboxFile.link);
|
|
||||||
oAttachment.waiting(false).uploading(true).complete(false);
|
|
||||||
|
|
||||||
this.attachments.push(oAttachment);
|
|
||||||
|
|
||||||
this.attachmentsPlace(true);
|
|
||||||
|
|
||||||
if (0 < mSize && 0 < iAttachmentSizeLimit && iAttachmentSizeLimit < mSize)
|
if (0 < mSize && 0 < iAttachmentSizeLimit && iAttachmentSizeLimit < mSize)
|
||||||
{
|
{
|
||||||
|
@ -1940,20 +1938,8 @@ ComposePopupView.prototype.addDriveAttachment = function(oDriveFile, sAccessToke
|
||||||
{
|
{
|
||||||
var
|
var
|
||||||
iAttachmentSizeLimit = Utils.pInt(Settings.settingsGet('AttachmentLimit')),
|
iAttachmentSizeLimit = Utils.pInt(Settings.settingsGet('AttachmentLimit')),
|
||||||
oAttachment = null,
|
mSize = oDriveFile.fileSize ? Utils.pInt(oDriveFile.fileSize) : 0,
|
||||||
mSize = oDriveFile.fileSize ? Utils.pInt(oDriveFile.fileSize) : 0;
|
oAttachment = this.addAttachmentHelper(oDriveFile.downloadUrl, oDriveFile.title, mSize);
|
||||||
|
|
||||||
oAttachment = new ComposeAttachmentModel(
|
|
||||||
oDriveFile.downloadUrl, oDriveFile.title, mSize
|
|
||||||
);
|
|
||||||
|
|
||||||
oAttachment.fromMessage = false;
|
|
||||||
oAttachment.cancel = this.cancelAttachmentHelper(oDriveFile.downloadUrl);
|
|
||||||
oAttachment.waiting(false).uploading(true).complete(false);
|
|
||||||
|
|
||||||
this.attachments.push(oAttachment);
|
|
||||||
|
|
||||||
this.attachmentsPlace(true);
|
|
||||||
|
|
||||||
if (0 < mSize && 0 < iAttachmentSizeLimit && iAttachmentSizeLimit < mSize)
|
if (0 < mSize && 0 < iAttachmentSizeLimit && iAttachmentSizeLimit < mSize)
|
||||||
{
|
{
|
||||||
|
@ -1995,25 +1981,15 @@ ComposePopupView.prototype.prepearMessageAttachments = function(oMessage, sType)
|
||||||
{
|
{
|
||||||
if (oMessage)
|
if (oMessage)
|
||||||
{
|
{
|
||||||
var
|
|
||||||
aAttachments = Utils.isNonEmptyArray(oMessage.attachments()) ? oMessage.attachments() : [],
|
|
||||||
iIndex = 0,
|
|
||||||
iLen = aAttachments.length,
|
|
||||||
oAttachment = null,
|
|
||||||
oItem = null,
|
|
||||||
bAdd = false;
|
|
||||||
|
|
||||||
if (Enums.ComposeType.ForwardAsAttachment === sType)
|
if (Enums.ComposeType.ForwardAsAttachment === sType)
|
||||||
{
|
{
|
||||||
this.addMessageAsAttachment(oMessage);
|
this.addMessageAsAttachment(oMessage);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (; iIndex < iLen; iIndex++)
|
var aAttachments = oMessage.attachments();
|
||||||
{
|
_.each(Utils.isNonEmptyArray(aAttachments) ? aAttachments : [], function(oItem) {
|
||||||
oItem = aAttachments[iIndex];
|
var bAdd = false;
|
||||||
|
|
||||||
bAdd = false;
|
|
||||||
switch (sType)
|
switch (sType)
|
||||||
{
|
{
|
||||||
case Enums.ComposeType.Reply:
|
case Enums.ComposeType.Reply:
|
||||||
|
@ -2031,7 +2007,7 @@ ComposePopupView.prototype.prepearMessageAttachments = function(oMessage, sType)
|
||||||
|
|
||||||
if (bAdd)
|
if (bAdd)
|
||||||
{
|
{
|
||||||
oAttachment = new ComposeAttachmentModel(
|
var oAttachment = new ComposeAttachmentModel(
|
||||||
oItem.download, oItem.fileName, oItem.estimatedSize,
|
oItem.download, oItem.fileName, oItem.estimatedSize,
|
||||||
oItem.isInline, oItem.isLinked, oItem.cid, oItem.contentLocation
|
oItem.isInline, oItem.isLinked, oItem.cid, oItem.contentLocation
|
||||||
);
|
);
|
||||||
|
@ -2042,7 +2018,7 @@ ComposePopupView.prototype.prepearMessageAttachments = function(oMessage, sType)
|
||||||
|
|
||||||
this.attachments.push(oAttachment);
|
this.attachments.push(oAttachment);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue