diff options
| author | Adam Soltys <[email protected]> | 2026-10-18 23:32:31 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-18 23:32:31 -0700 |
| commit | a99d37ca24e6484d8c2edd2ec7ac7dcaf4f29809 (patch) | |
| tree | e984d45a06a73fecfa2e70f5a6329e51e8ac94be /src/nostr.js | |
| parent | 7367343cb45d08bcc0f5e3246c8c5462ea204281 (diff) | |
| download | coinosv3-a99d37ca24e6484d8c2edd2ec7ac7dcaf4f29809.tar.gz coinosv3-a99d37ca24e6484d8c2edd2ec7ac7dcaf4f29809.zip | |
DMs and calls go to relay.coinos.io and relay.primal.net (both take gift wraps and pass call messages on live), not nos.lol, which refused or ignored the household IP's publishes. A relay that turns a call message away is left out of the next ones on this device: a day for one that won't take the kind (nip17.com: only kind 1059), ten minutes for a rate limit or ban. publishOn tells its caller which relay refused and why (onrefused).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013ZDf1cyCQLkfjftYhymZAg
Diffstat (limited to 'src/nostr.js')
| -rw-r--r-- | src/nostr.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nostr.js b/src/nostr.js index 8dcab01..c77fc27 100644 --- a/src/nostr.js +++ b/src/nostr.js @@ -498,7 +498,7 @@ export async function queryStreamOn(relays, filter, onEvent, maxWait = 1500) { }); } catch {} finally { await Promise.all(pending); } } -export async function publishOn(relays, evt, { onauth = null } = {}) { +export async function publishOn(relays, evt, { onauth = null, onrefused = null } = {}) { try { const live = liveRelays(relays); // A rejected publish is a relay refusing the event (policy, rate limit, @@ -520,7 +520,12 @@ export async function publishOn(relays, evt, { onauth = null } = {}) { // "relay connection errored/closed" means the socket never came up — // that's a sick relay, not a rejected event. if (/connect|closed|errored|timeout|network/i.test(msg)) markRelaySick(live[i], msg); - else console.warn(`nostr: publish kind ${evt.kind} refused by ${live[i]}:`, msg); + else { + console.warn(`nostr: publish kind ${evt.kind} refused by ${live[i]}:`, msg); + // the relay said no to this event (policy, a rate limit, a ban): a + // caller can stop asking it + if (onrefused) try { onrefused(live[i], msg); } catch {} + } return false; })); // The first acceptance IS delivery — one durable copy is enough, and |
