This commit is contained in:
Daniel Lugo 2020-02-24 18:40:28 -04:00
parent 89d1f1bacf
commit 0488e322b6

View file

@ -57,22 +57,12 @@ const __createOutgoingFeed = async (withPublicKey, user, SEA) => {
user._.sea user._.sea
) )
const maybeEncryptedForMeOutgoingFeedID = await Utils.tryAndWait( const maybeOutgoingID = await Utils.recipientToOutgoingID(withPublicKey)
(_, user) =>
new Promise(res => {
user
.get(Key.RECIPIENT_TO_OUTGOING)
.get(withPublicKey)
.once(data => {
res(data)
})
})
)
let outgoingFeedID = '' let outgoingFeedID = ''
// if there was no stored outgoing, create an outgoing feed // if there was no stored outgoing, create an outgoing feed
if (typeof maybeEncryptedForMeOutgoingFeedID !== 'string') { if (typeof maybeOutgoingID !== 'string') {
/** @type {PartialOutgoing} */ /** @type {PartialOutgoing} */
const newPartialOutgoingFeed = { const newPartialOutgoingFeed = {
with: encryptedForMeRecipientPub with: encryptedForMeRecipientPub
@ -138,18 +128,7 @@ const __createOutgoingFeed = async (withPublicKey, user, SEA) => {
// otherwise decrypt stored outgoing // otherwise decrypt stored outgoing
else { else {
const decryptedOID = await SEA.decrypt( outgoingFeedID = maybeOutgoingID
maybeEncryptedForMeOutgoingFeedID,
mySecret
)
if (typeof decryptedOID !== 'string') {
throw new TypeError(
"__createOutgoingFeed() -> typeof decryptedOID !== 'string'"
)
}
outgoingFeedID = decryptedOID
} }
if (typeof outgoingFeedID === 'undefined') { if (typeof outgoingFeedID === 'undefined') {