From 4e8f0761fc3cdf6da89263aa08a3bf60a14eedc2 Mon Sep 17 00:00:00 2001 From: Pirate Praveen Date: Fri, 24 May 2024 19:23:27 +0530 Subject: [PATCH] Fix key removal for ferretdb compat --- src/modules/public-key.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/modules/public-key.js b/src/modules/public-key.js index 369a94e..bb0b2b1 100644 --- a/src/modules/public-key.js +++ b/src/modules/public-key.js @@ -345,7 +345,19 @@ class PublicKey { // flag only the provided user id if (email) { const nonce = util.random(); - await this._mongo.update(query, {'userIds.$.nonce': nonce}, DB_TYPE); + const flaggedUserIds = key.userIds.map(uid => { + if (uid.email === email) { + return { + nonce: nonce, + verified: uid.verified, + publicKeyArmored: uid.publicKeyArmored, + name: uid.name, + email: uid.email + } + } + return uid; + }); + await this._mongo.update({'_id':key['_id']}, {userIds: flaggedUserIds}, DB_TYPE); const uid = key.userIds.find(u => u.email === email); uid.nonce = nonce; return {userIds: [uid], keyId: key.keyId};