Skip to content

Commit

Permalink
in case we have some reference with the owner in our db, we should de…
Browse files Browse the repository at this point in the history
…lete it before adding an invitation dummy, if it is not there it shouldn't be a problem either
  • Loading branch information
silkroadnomad committed Apr 1, 2024
1 parent d11e7cd commit 7a8e4ef
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/lib/network/p2p-operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,19 +382,20 @@ export const requestAddress = async (_scannedAddress,nopingpong, onBoardingToken

//look if a dummy is inside
const all = await _dbMyAddressBook.all()
const foundDummy = all.filter((it) => { return it.value.owner === scannedAddress})

if(foundDummy.length===0){
const dummyContact = {
owner: scannedAddress,
firstName: 'invited',
lastName: scannedAddress
}
if(onBoardingToken!==undefined) dummyContact.onBoardingToken = onBoardingToken

dummyContact._id = await sha256(JSON.stringify(dummyContact));
await _dbMyAddressBook.put(dummyContact)
const foundDummy = all.filter((it) => { return it.value.owner === scannedAddress })
await _dbMyAddressBook.del(foundDummy[0].key)
// if(foundDummy.length===0){
const dummyContact = {
owner: scannedAddress,
firstName: 'invited',
lastName: scannedAddress
}
if(onBoardingToken!==undefined) dummyContact.onBoardingToken = onBoardingToken

dummyContact._id = await sha256(JSON.stringify(dummyContact));
await _dbMyAddressBook.put(dummyContact)
// }

//TODO when publishing, sign and encrypt message
await _libp2p.services.pubsub.publish(CONTENT_TOPIC+"/"+scannedAddress, new TextEncoder().encode(JSON.stringify(msg)))
Expand Down

0 comments on commit 7a8e4ef

Please sign in to comment.