await all
This commit is contained in:
parent
9b8e1c32c8
commit
5a73f1d91b
1 changed files with 15 additions and 4 deletions
|
|
@ -169,10 +169,21 @@ export default class Handler {
|
|||
}
|
||||
|
||||
const signed = finishEvent(toSign, appInfo.privateKey)
|
||||
this.pool.publish(relays || this.settings.relays, signed).forEach(p => {
|
||||
p.then(() => console.log("sent ok"))
|
||||
p.catch(() => console.log("failed to send"))
|
||||
})
|
||||
let sent = false
|
||||
const log = getLogger({ appName: appInfo.name })
|
||||
await Promise.all(this.pool.publish(relays || this.settings.relays, signed).map(async p => {
|
||||
try {
|
||||
await p
|
||||
sent = true
|
||||
} catch (e: any) {
|
||||
log(e)
|
||||
}
|
||||
}))
|
||||
if (!sent) {
|
||||
log("failed to send event")
|
||||
} else {
|
||||
log("event sent ok")
|
||||
}
|
||||
}
|
||||
|
||||
GetAppKeys(appInfo: Partial<AppInfo>) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue