This commit is contained in:
Daniel Lugo 2020-01-29 19:19:02 -04:00
parent f96114b7fc
commit 3d685eb714

View file

@ -120,6 +120,8 @@ const notifyIncomingsListeners = () => {
/** @type {Set<string>} */
const pubFeedPairsWithIncomingListeners = new Set()
let subbed = false
/**
* @param {IncomingsListener} cb
*/
@ -129,6 +131,7 @@ const onIncoming = cb => {
const user = require('../../Mediator').getUser()
const SEA = require('../../Mediator').mySEA
if (!subbed) {
user.get(Key.USER_TO_INCOMING).open(uti => {
if (typeof uti !== 'object' || uti === null) {
return
@ -138,7 +141,10 @@ const onIncoming = cb => {
if (typeof encFeed !== 'string') {
return
}
const ourSecret = await SEA.secret(await Utils.pubToEpub(pub), user._.sea)
const ourSecret = await SEA.secret(
await Utils.pubToEpub(pub),
user._.sea
)
const mySecret = await Utils.mySecret()
const feed = await SEA.decrypt(encFeed, mySecret)
@ -199,12 +205,19 @@ const onIncoming = cb => {
}
)
console.log('--------------------------------')
console.log(`msgs: ${JSON.stringify(msgs)}`)
console.log('--------------------------------')
notifyIncomingsListeners()
})
}
})
})
subbed = true
}
return () => {
incomingsListeners.delete(cb)
}