fix: properly handle async NostrSend calls for Kind 21002 responses #1
5 changed files with 8 additions and 7 deletions
|
|
@ -105,7 +105,7 @@ export default (serverMethods: Types.ServerMethods, mainHandler: Main, nostrSett
|
|||
|
||||
return {
|
||||
Stop: () => { mainHandler.adminManager.setNostrConnected(false); return nostr.Stop },
|
||||
Send: (...args) => nostr.Send(...args),
|
||||
Send: async (...args) => nostr.Send(...args),
|
||||
Ping: () => nostr.Ping(),
|
||||
Reset: (settings: NostrSettings) => nostr.Reset(settings)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,13 +153,14 @@ export class DebitManager {
|
|||
}
|
||||
|
||||
notifyPaymentSuccess = (debitRes: NdebitSuccess, event: { pub: string, id: string, appId: string }) => {
|
||||
this.logger("✅ [DEBIT REQUEST] Payment successful, sending OK response to", event.pub.slice(0, 16) + "...", "for event", event.id.slice(0, 16) + "...")
|
||||
this.sendDebitResponse(debitRes, event)
|
||||
}
|
||||
|
||||
sendDebitResponse = (debitRes: NdebitFailure | NdebitSuccess, event: { pub: string, id: string, appId: string }) => {
|
||||
this.logger("📤 [DEBIT RESPONSE] Sending Kind 21002 response:", JSON.stringify(debitRes), "to", event.pub.slice(0, 16) + "...")
|
||||
const e = newNdebitResponse(JSON.stringify(debitRes), event)
|
||||
this.storage.NostrSender().Send({ type: 'app', appId: event.appId }, { type: 'event', event: e, encrypt: { toPub: event.pub } })
|
||||
|
||||
}
|
||||
|
||||
payNdebitInvoice = async (event: NostrEvent, pointerdata: NdebitData): Promise<HandleNdebitRes> => {
|
||||
|
|
|
|||
|
|
@ -132,12 +132,12 @@ const handleNostrSettings = (settings: NostrSettings) => {
|
|||
send(event)
|
||||
})
|
||||
} */
|
||||
const sendToNostr: NostrSend = (initiator, data, relays) => {
|
||||
const sendToNostr: NostrSend = async (initiator, data, relays) => {
|
||||
if (!subProcessHandler) {
|
||||
getLogger({ component: "nostrMiddleware" })(ERROR, "nostr was not initialized")
|
||||
return
|
||||
}
|
||||
subProcessHandler.Send(initiator, data, relays)
|
||||
await subProcessHandler.Send(initiator, data, relays)
|
||||
}
|
||||
|
||||
send({ type: 'ready' })
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ class TlvFilesStorageProcessor {
|
|||
throw new Error('Unknown metric type: ' + t)
|
||||
}
|
||||
})
|
||||
this.wrtc.attachNostrSend((initiator: SendInitiator, data: SendData, relays?: string[] | undefined) => {
|
||||
this.wrtc.attachNostrSend(async (initiator: SendInitiator, data: SendData, relays?: string[] | undefined) => {
|
||||
this.sendResponse({
|
||||
success: true,
|
||||
type: 'nostrSend',
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ export default class webRTC {
|
|||
attachNostrSend(f: NostrSend) {
|
||||
this._nostrSend = f
|
||||
}
|
||||
private nostrSend: NostrSend = (initiator: SendInitiator, data: SendData, relays?: string[] | undefined) => {
|
||||
private nostrSend: NostrSend = async (initiator: SendInitiator, data: SendData, relays?: string[] | undefined) => {
|
||||
if (!this._nostrSend) {
|
||||
throw new Error("No nostrSend attached")
|
||||
}
|
||||
this._nostrSend(initiator, data, relays)
|
||||
await this._nostrSend(initiator, data, relays)
|
||||
}
|
||||
|
||||
private sendCandidate = (u: WebRtcUserInfo, candidate: string) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue