delete stored req on successful connect
This commit is contained in:
parent
b108027ba5
commit
806ff0bab7
1 changed files with 26 additions and 5 deletions
|
|
@ -33,7 +33,7 @@ const onAcceptedRequests = async (user, SEA) => {
|
||||||
user
|
user
|
||||||
.get(Key.STORED_REQS)
|
.get(Key.STORED_REQS)
|
||||||
.map()
|
.map()
|
||||||
.once(async storedReq => {
|
.once(async (storedReq, id) => {
|
||||||
try {
|
try {
|
||||||
if (!Schema.isStoredRequest(storedReq)) {
|
if (!Schema.isStoredRequest(storedReq)) {
|
||||||
throw new TypeError('Stored request not an StoredRequest')
|
throw new TypeError('Stored request not an StoredRequest')
|
||||||
|
|
@ -123,10 +123,31 @@ const onAcceptedRequests = async (user, SEA) => {
|
||||||
mySecret
|
mySecret
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await new Promise((res, rej) => {
|
||||||
user
|
user
|
||||||
.get(Key.USER_TO_INCOMING)
|
.get(Key.USER_TO_INCOMING)
|
||||||
.get(recipientPub)
|
.get(recipientPub)
|
||||||
.put(encryptedForMeIncomingID)
|
.put(encryptedForMeIncomingID, ack => {
|
||||||
|
if (ack.err) {
|
||||||
|
rej(new Error(ack.err))
|
||||||
|
} else {
|
||||||
|
res()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
await new Promise((res, rej) => {
|
||||||
|
user
|
||||||
|
.get(Key.STORED_REQS)
|
||||||
|
.get(id)
|
||||||
|
.put(null, ack => {
|
||||||
|
if (ack.err) {
|
||||||
|
rej(new Error(ack.err))
|
||||||
|
} else {
|
||||||
|
res()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// ensure this listeners gets called at least once
|
// ensure this listeners gets called at least once
|
||||||
res()
|
res()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue