fix(nostr): correct nostr-tools API usage for subscribe and publish
Two bugs fixed:
1. subscribeMany filter incorrectly wrapped in array
- Was: `pool.subscribeMany(relays, [{ kinds: [4], ... }], ...)`
- Fix: `pool.subscribeMany(relays, { kinds: [4], ... }, ...)`
- subscribeMany expects `Filter`, not `Filter[]`
- This prevented inbound NIP-04 DMs from being received
2. publish return value not properly awaited
- Was: `await pool.publish([relay], event)`
- Fix: `await pool.publish([relay], event)[0]`
- publish returns `Promise<string>[]`, not `Promise<string>`
- Awaiting an array doesn't resolve the promises inside
- This meant errors weren't caught and success was assumed prematurely
This commit is contained in:
parent
6859e1e6a6
commit
69a7b8e89a
@ -512,7 +512,7 @@ export async function startNostrBus(
|
||||
|
||||
const sub = pool.subscribeMany(
|
||||
relays,
|
||||
[{ kinds: [4], "#p": [pk], since }],
|
||||
{ kinds: [4], "#p": [pk], since },
|
||||
{
|
||||
onevent: handleEvent,
|
||||
oneose: () => {
|
||||
@ -657,7 +657,7 @@ async function sendEncryptedDm(
|
||||
|
||||
const startTime = Date.now();
|
||||
try {
|
||||
await pool.publish([relay], reply);
|
||||
await pool.publish([relay], reply)[0];
|
||||
const latency = Date.now() - startTime;
|
||||
|
||||
// Record success
|
||||
|
||||
Loading…
Reference in New Issue
Block a user