From 0488e322b68e705fd796808251dce2983a58986a Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Mon, 24 Feb 2020 18:40:28 -0400 Subject: [PATCH] use util --- services/gunDB/contact-api/actions.js | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/services/gunDB/contact-api/actions.js b/services/gunDB/contact-api/actions.js index 0235b296..af3942c4 100644 --- a/services/gunDB/contact-api/actions.js +++ b/services/gunDB/contact-api/actions.js @@ -57,22 +57,12 @@ const __createOutgoingFeed = async (withPublicKey, user, SEA) => { user._.sea ) - const maybeEncryptedForMeOutgoingFeedID = await Utils.tryAndWait( - (_, user) => - new Promise(res => { - user - .get(Key.RECIPIENT_TO_OUTGOING) - .get(withPublicKey) - .once(data => { - res(data) - }) - }) - ) + const maybeOutgoingID = await Utils.recipientToOutgoingID(withPublicKey) let outgoingFeedID = '' // if there was no stored outgoing, create an outgoing feed - if (typeof maybeEncryptedForMeOutgoingFeedID !== 'string') { + if (typeof maybeOutgoingID !== 'string') { /** @type {PartialOutgoing} */ const newPartialOutgoingFeed = { with: encryptedForMeRecipientPub @@ -138,18 +128,7 @@ const __createOutgoingFeed = async (withPublicKey, user, SEA) => { // otherwise decrypt stored outgoing else { - const decryptedOID = await SEA.decrypt( - maybeEncryptedForMeOutgoingFeedID, - mySecret - ) - - if (typeof decryptedOID !== 'string') { - throw new TypeError( - "__createOutgoingFeed() -> typeof decryptedOID !== 'string'" - ) - } - - outgoingFeedID = decryptedOID + outgoingFeedID = maybeOutgoingID } if (typeof outgoingFeedID === 'undefined') {