This commit is contained in:
boufni95 2023-12-15 20:37:42 +01:00
parent b10f2b4668
commit 5a4ac382ad
2 changed files with 6 additions and 3 deletions

View file

@ -10,7 +10,8 @@ export default (serverMethods: Types.ServerMethods, mainHandler: Main, nostrSett
const app = await mainHandler.storage.applicationStorage.GetApplication(appId || "")
let nostrUser = await mainHandler.storage.applicationStorage.GetOrCreateNostrAppUser(app, pub || "")
return { user_id: nostrUser.user.user_id, app_user_id: nostrUser.identifier, app_id: appId || "" }
}
},
metricsCallback: metrics => mainHandler.metricsManager.AddMetrics(metrics)
})
const nostr = new Nostr(nostrSettings, event => {
let j: NostrRequest
@ -22,7 +23,7 @@ export default (serverMethods: Types.ServerMethods, mainHandler: Main, nostrSett
}
nostrTransport({ ...j, appId: event.appId }, res => {
nostr.Send(event.appId, { type: 'content', pub: event.pub, content: JSON.stringify({ ...res, requestId: j.requestId }) })
})
}, event.startAtNano)
})
return { Stop: () => nostr.Stop, Send: (...args) => nostr.Send(...args) }
}

View file

@ -16,6 +16,7 @@ export type NostrEvent = {
pub: string
content: string
appId: string
startAtNano: bigint
}
type SettingsRequest = {
type: 'settings'
@ -141,9 +142,10 @@ export default class Handler {
return
}
handledEvents.push(eventId)
const startAtNano = process.hrtime.bigint()
const decoded = decodePayload(e.content)
const content = await decryptData(decoded, getSharedSecret(app.privateKey, e.pubkey))
this.eventCallback({ id: eventId, content, pub: e.pubkey, appId: app.appId })
this.eventCallback({ id: eventId, content, pub: e.pubkey, appId: app.appId, startAtNano })
})