Optimize key removal during verification

This commit is contained in:
Tankred Hase 2017-08-25 16:20:33 +08:00 committed by GitHub
parent 77fc0fd195
commit b93db84c6a

View File

@ -152,12 +152,10 @@ class PublicKey {
}
async _removeKeysWithSameEmail({keyId, userIds}, nonce) {
const {email} = userIds.find(uid => uid.nonce === nonce);
const keys = await this._mongo.list({
return this._mongo.remove({
keyId: {$ne: keyId},
'userIds.email': email
'userIds.email': userIds.find(u => u.nonce === nonce).email
}, DB_TYPE);
await Promise.all(keys.map(({_id}) => this._mongo.remove({_id}, DB_TYPE)));
}
/**