Code refactoring (Q -> Promise)

This commit is contained in:
RainLoop Team 2016-05-23 20:33:01 +03:00
parent 7e4479d655
commit 1323a9ce52
10 changed files with 164 additions and 139 deletions

View file

@ -9,6 +9,7 @@
kn = require('Knoin/Knoin'),
Translator = require('Common/Translator'),
Settings = require('Storage/Settings'),
Utils = require('Common/Utils')
;
@ -237,6 +238,23 @@
return false;
};
PgpUserStore.prototype.findKeyExternal = function (sEmail, fCallback)
{
if (this.openpgp.HKP && Settings.appSettingsGet('openpgpPublicKeyServer'))
{
var oHkp = new this.openpgp.HKP(Settings.appSettingsGet('openpgpPublicKeyServer').replace(/\/$/, ''));
oHkp.lookup({query: sEmail}).then(function(sKey) {
fCallback(sKey);
}, function() {
fCallback(null);
});
}
else
{
fCallback(null);
}
};
PgpUserStore.prototype.verifyMessage = function (oMessage, fCallback)
{
var oValid = null, aResult = [], aPublicKeys = [], aSigningKeyIds = [];
@ -245,6 +263,10 @@
aSigningKeyIds = oMessage.getSigningKeyIds();
if (aSigningKeyIds && 0 < aSigningKeyIds.length)
{
// this.findKeyExternal('support@rainloop.net', function(key) {
// console.log(key);
// });
aPublicKeys = this.findPublicKeysBySigningKeyIds(aSigningKeyIds);
if (aPublicKeys && 0 < aPublicKeys.length)
{