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>} */ /** @type {Set<string>} */
const pubFeedPairsWithIncomingListeners = new Set() const pubFeedPairsWithIncomingListeners = new Set()
let subbed = false
/** /**
* @param {IncomingsListener} cb * @param {IncomingsListener} cb
*/ */
@ -129,6 +131,7 @@ const onIncoming = cb => {
const user = require('../../Mediator').getUser() const user = require('../../Mediator').getUser()
const SEA = require('../../Mediator').mySEA const SEA = require('../../Mediator').mySEA
if (!subbed) {
user.get(Key.USER_TO_INCOMING).open(uti => { user.get(Key.USER_TO_INCOMING).open(uti => {
if (typeof uti !== 'object' || uti === null) { if (typeof uti !== 'object' || uti === null) {
return return
@ -138,7 +141,10 @@ const onIncoming = cb => {
if (typeof encFeed !== 'string') { if (typeof encFeed !== 'string') {
return 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 mySecret = await Utils.mySecret()
const feed = await SEA.decrypt(encFeed, 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() notifyIncomingsListeners()
}) })
} }
}) })
}) })
subbed = true
}
return () => { return () => {
incomingsListeners.delete(cb) incomingsListeners.delete(cb)
} }