mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 21:19:21 +03: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
|
||||
self = this,
|
||||
iUnseenCount = 0,
|
||||
oMessage = null,
|
||||
sTrashFolder = FolderStore.trashFolder(),
|
||||
sSpamFolder = FolderStore.spamFolder(),
|
||||
aMessageList = this.messageList(),
|
||||
|
|
@ -415,7 +414,7 @@ MessageUserStore.prototype.removeMessagesFromList = function(
|
|||
return !!(item && item.deleted() && item.uid === self.messageListThreadUid());
|
||||
}))
|
||||
{
|
||||
oMessage = _.find(aMessageList, function(item) {
|
||||
var oMessage = _.find(aMessageList, function(item) {
|
||||
return item && !item.deleted();
|
||||
});
|
||||
|
||||
|
|
@ -510,25 +509,19 @@ MessageUserStore.prototype.setMessage = function(oData, bCached)
|
|||
{
|
||||
var
|
||||
bNew = false,
|
||||
bIsHtml = false,
|
||||
bHasExternals = false,
|
||||
bHasInternals = false,
|
||||
oBody = null,
|
||||
oTextBody = null,
|
||||
sId = '',
|
||||
sPlain = '',
|
||||
sResultHtml = '',
|
||||
bPgpSigned = false,
|
||||
bPgpEncrypted = false,
|
||||
oMessagesDom = this.messagesBodiesDom(),
|
||||
oSelectedMessage = this.selectorMessageSelected(),
|
||||
oMessage = this.message(),
|
||||
aThreads = [];
|
||||
oMessage = this.message();
|
||||
|
||||
if (oData && oMessage && oData.Result && 'Object/Message' === oData.Result['@Object'] &&
|
||||
oMessage.folderFullNameRaw === oData.Result.Folder)
|
||||
{
|
||||
aThreads = oMessage.threads();
|
||||
var aThreads = oMessage.threads();
|
||||
if (oMessage.uid !== oData.Result.Uid && 1 < aThreads.length &&
|
||||
-1 < Utils.inArray(oData.Result.Uid, aThreads))
|
||||
{
|
||||
|
|
@ -561,13 +554,11 @@ MessageUserStore.prototype.setMessage = function(oData, bCached)
|
|||
if (oMessagesDom)
|
||||
{
|
||||
sId = 'rl-mgs-' + oMessage.hash.replace(/[^a-zA-Z0-9]/g, '');
|
||||
oTextBody = oMessagesDom.find('#' + sId);
|
||||
|
||||
var oTextBody = oMessagesDom.find('#' + sId);
|
||||
if (!oTextBody || !oTextBody[0])
|
||||
{
|
||||
bHasExternals = !!oData.Result.HasExternals;
|
||||
bHasInternals = !!oData.Result.HasInternals;
|
||||
|
||||
var bIsHtml = false;
|
||||
if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html)
|
||||
{
|
||||
bIsHtml = true;
|
||||
|
|
@ -582,7 +573,7 @@ MessageUserStore.prototype.setMessage = function(oData, bCached)
|
|||
{
|
||||
sPlain = Utils.pString(oData.Result.Plain);
|
||||
|
||||
bPgpEncrypted = (/---BEGIN PGP MESSAGE---/).test(sPlain);
|
||||
var bPgpEncrypted = (/---BEGIN PGP MESSAGE---/).test(sPlain);
|
||||
if (!bPgpEncrypted)
|
||||
{
|
||||
bPgpSigned = (/-----BEGIN PGP SIGNED MESSAGE-----/).test(sPlain) &&
|
||||
|
|
@ -609,8 +600,6 @@ MessageUserStore.prototype.setMessage = function(oData, bCached)
|
|||
sResultHtml = '<pre>' + sResultHtml + '</pre>';
|
||||
}
|
||||
|
||||
sPlain = '';
|
||||
|
||||
Globals.$div.empty();
|
||||
|
||||
oMessage.isPgpSigned(bPgpSigned);
|
||||
|
|
@ -637,7 +626,7 @@ MessageUserStore.prototype.setMessage = function(oData, bCached)
|
|||
.addClass('b-text-part ' + (bIsHtml ? 'html' : 'plain'));
|
||||
|
||||
oMessage.isHtml(!!bIsHtml);
|
||||
oMessage.hasImages(!!bHasExternals);
|
||||
oMessage.hasImages(!!oData.Result.HasExternals);
|
||||
|
||||
oMessage.body = oBody;
|
||||
if (oMessage.body)
|
||||
|
|
@ -647,7 +636,7 @@ MessageUserStore.prototype.setMessage = function(oData, bCached)
|
|||
|
||||
oMessage.storeDataInDom();
|
||||
|
||||
if (bHasInternals)
|
||||
if (oData.Result.HasInternals)
|
||||
{
|
||||
oMessage.showInternalImages(true);
|
||||
}
|
||||
|
|
@ -815,14 +804,9 @@ MessageUserStore.prototype.setMessageList = function(oData, bCached)
|
|||
oData.Result['@Collection'] && Utils.isArray(oData.Result['@Collection']))
|
||||
{
|
||||
var
|
||||
iIndex = 0,
|
||||
iLen = 0,
|
||||
iCount = 0,
|
||||
iOffset = 0,
|
||||
aList = [],
|
||||
oJsonMessage = null,
|
||||
oMessage = null,
|
||||
oFolder = null,
|
||||
iNewCount = 0,
|
||||
iUtc = require('Common/Momentor').momentNowUnix(),
|
||||
bUnreadCountChange = false;
|
||||
|
|
@ -830,9 +814,7 @@ MessageUserStore.prototype.setMessageList = function(oData, bCached)
|
|||
iCount = Utils.pInt(oData.Result.MessageResultCount);
|
||||
iOffset = Utils.pInt(oData.Result.Offset);
|
||||
|
||||
oFolder = Cache.getFolderFromCacheList(
|
||||
Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : '');
|
||||
|
||||
var oFolder = Cache.getFolderFromCacheList(Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : '');
|
||||
if (oFolder && !bCached)
|
||||
{
|
||||
oFolder.interval = iUtc;
|
||||
|
|
@ -862,12 +844,10 @@ MessageUserStore.prototype.setMessageList = function(oData, bCached)
|
|||
Cache.clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw);
|
||||
}
|
||||
|
||||
for (iIndex = 0, iLen = oData.Result['@Collection'].length; iIndex < iLen; iIndex++)
|
||||
{
|
||||
oJsonMessage = oData.Result['@Collection'][iIndex];
|
||||
_.each(oData.Result['@Collection'], function(oJsonMessage) {
|
||||
if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object'])
|
||||
{
|
||||
oMessage = MessageModel.newInstanceFromJson(oJsonMessage);
|
||||
var oMessage = MessageModel.newInstanceFromJson(oJsonMessage);
|
||||
if (oMessage)
|
||||
{
|
||||
if (Cache.hasNewMessageAndRemoveFromCache(oMessage.folderFullNameRaw, oMessage.uid) && 5 >= iNewCount)
|
||||
|
|
@ -890,7 +870,7 @@ MessageUserStore.prototype.setMessageList = function(oData, bCached)
|
|||
aList.push(oMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.messageListCount(iCount);
|
||||
this.messageListSearch(Utils.isNormal(oData.Result.Search) ? oData.Result.Search : '');
|
||||
|
|
|
|||
|
|
@ -77,12 +77,10 @@ PgpUserStore.prototype.findPrivateKeysByEncryptionKeyIds = function(aEncryptionK
|
|||
{
|
||||
var
|
||||
self = this,
|
||||
aResult = [];
|
||||
|
||||
aResult = Utils.isArray(aEncryptionKeyIds) ? _.compact(_.flatten(_.map(aEncryptionKeyIds, function(oId) {
|
||||
var oKey = oId && oId.toHex ? self.findPrivateKeyByHex(oId.toHex()) : null;
|
||||
return oKey ? (bReturnWrapKeys ? [oKey] : oKey.getNativeKeys()) : [null];
|
||||
}), true)) : [];
|
||||
aResult = Utils.isArray(aEncryptionKeyIds) ? _.compact(_.flatten(_.map(aEncryptionKeyIds, function(oId) {
|
||||
var oKey = oId && oId.toHex ? self.findPrivateKeyByHex(oId.toHex()) : null;
|
||||
return oKey ? (bReturnWrapKeys ? [oKey] : oKey.getNativeKeys()) : [null];
|
||||
}), true)) : [];
|
||||
|
||||
if (0 === aResult.length && Utils.isNonEmptyArray(aRecipients))
|
||||
{
|
||||
|
|
@ -149,7 +147,6 @@ PgpUserStore.prototype.findAllPrivateKeysByEmailNotNative = function(sEmail)
|
|||
PgpUserStore.prototype.findPrivateKeyByEmail = function(sEmail, sPassword)
|
||||
{
|
||||
var
|
||||
oPrivateKeys = [],
|
||||
oPrivateKey = null,
|
||||
oKey = _.find(this.openpgpkeysPrivate(), function(oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
|
|
@ -157,11 +154,9 @@ PgpUserStore.prototype.findPrivateKeyByEmail = function(sEmail, sPassword)
|
|||
|
||||
if (oKey)
|
||||
{
|
||||
oPrivateKeys = oKey.getNativeKeys();
|
||||
oPrivateKey = oPrivateKeys[0] || null;
|
||||
|
||||
try
|
||||
{
|
||||
oPrivateKey = oKey.getNativeKeys()[0] || null;
|
||||
if (oPrivateKey)
|
||||
{
|
||||
oPrivateKey.decrypt(Utils.pString(sPassword));
|
||||
|
|
@ -187,13 +182,11 @@ PgpUserStore.prototype.findSelfPrivateKey = function(sPassword)
|
|||
|
||||
PgpUserStore.prototype.decryptMessage = function(oMessage, aRecipients, fCallback)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
aPrivateKeys = [];
|
||||
|
||||
if (oMessage && oMessage.getEncryptionKeyIds)
|
||||
{
|
||||
aPrivateKeys = this.findPrivateKeysByEncryptionKeyIds(oMessage.getEncryptionKeyIds(), aRecipients, true);
|
||||
var self = this,
|
||||
aPrivateKeys = this.findPrivateKeysByEncryptionKeyIds(oMessage.getEncryptionKeyIds(), aRecipients, true);
|
||||
|
||||
if (aPrivateKeys && 0 < aPrivateKeys.length)
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/MessageOpenPgp'), [function(oDecryptedKey) {
|
||||
|
|
@ -260,29 +253,21 @@ PgpUserStore.prototype.findKeyExternal = function(sEmail, fCallback)
|
|||
|
||||
PgpUserStore.prototype.verifyMessage = function(oMessage, fCallback)
|
||||
{
|
||||
var
|
||||
aResult = [],
|
||||
aPublicKeys = [],
|
||||
aSigningKeyIds = [];
|
||||
|
||||
if (oMessage && oMessage.getSigningKeyIds)
|
||||
{
|
||||
aSigningKeyIds = oMessage.getSigningKeyIds();
|
||||
var aSigningKeyIds = oMessage.getSigningKeyIds();
|
||||
if (aSigningKeyIds && 0 < aSigningKeyIds.length)
|
||||
{
|
||||
// this.findKeyExternal('support@rainloop.net', function(key) {
|
||||
// console.log(key);
|
||||
// });
|
||||
|
||||
aPublicKeys = this.findPublicKeysBySigningKeyIds(aSigningKeyIds);
|
||||
var aPublicKeys = this.findPublicKeysBySigningKeyIds(aSigningKeyIds);
|
||||
if (aPublicKeys && 0 < aPublicKeys.length)
|
||||
{
|
||||
try
|
||||
{
|
||||
aResult = oMessage.verify(aPublicKeys);
|
||||
var oValid = _.find(_.isArray(aResult) ? aResult : [], function(oItem) {
|
||||
return oItem && oItem.valid && oItem.keyid;
|
||||
});
|
||||
var
|
||||
aResult = oMessage.verify(aPublicKeys),
|
||||
oValid = _.find(_.isArray(aResult) ? aResult : [], function(oItem) {
|
||||
return oItem && oItem.valid && oItem.keyid;
|
||||
});
|
||||
|
||||
if (oValid && oValid.keyid && oValid.keyid && oValid.keyid.toHex)
|
||||
{
|
||||
|
|
@ -333,8 +318,9 @@ PgpUserStore.prototype.controlsHelper = function(mDom, oVerControl, bSuccess, sT
|
|||
PgpUserStore.domControlEncryptedClickHelper = function(store, mDom, sArmoredMessage, aRecipients)
|
||||
{
|
||||
return function() {
|
||||
|
||||
var
|
||||
oMessage = null,
|
||||
message = null,
|
||||
$this = $(this);
|
||||
|
||||
if ($this.hasClass('success'))
|
||||
|
|
@ -344,16 +330,16 @@ PgpUserStore.domControlEncryptedClickHelper = function(store, mDom, sArmoredMess
|
|||
|
||||
try
|
||||
{
|
||||
oMessage = store.openpgp.message.readArmored(sArmoredMessage);
|
||||
message = store.openpgp.message.readArmored(sArmoredMessage);
|
||||
}
|
||||
catch (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)
|
||||
{
|
||||
|
|
@ -405,7 +391,7 @@ PgpUserStore.domControlSignedClickHelper = function(store, mDom, sArmoredMessage
|
|||
return function() {
|
||||
|
||||
var
|
||||
oMessage = null,
|
||||
message = null,
|
||||
$this = $(this);
|
||||
|
||||
if ($this.hasClass('success') || $this.hasClass('error'))
|
||||
|
|
@ -415,21 +401,21 @@ PgpUserStore.domControlSignedClickHelper = function(store, mDom, sArmoredMessage
|
|||
|
||||
try
|
||||
{
|
||||
oMessage = store.openpgp.cleartext.readArmored(sArmoredMessage);
|
||||
message = store.openpgp.cleartext.readArmored(sArmoredMessage);
|
||||
}
|
||||
catch (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)
|
||||
{
|
||||
store.controlsHelper(mDom, $this, true, Translator.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': oValidKey.user + ' (' + oValidKey.id + ')'
|
||||
}), oMessage.getText());
|
||||
}), message.getText());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue