diff options
| author | Adam Soltys <[email protected]> | 2026-10-02 22:40:33 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-02 22:40:33 -0700 |
| commit | c1f6d1340f47b89467381dd59ade2947e03bc470 (patch) | |
| tree | a69a18b01d7a62348a78f08d1635b3ea0f1ddc42 /src | |
| parent | 78f8e047f2e94e6065f6041c481387c7e6e20eec (diff) | |
| download | coinosv3-c1f6d1340f47b89467381dd59ade2947e03bc470.tar.gz coinosv3-c1f6d1340f47b89467381dd59ade2947e03bc470.zip | |
White Noise shows a coinos user's real name: the profile goes to its relays too
A coinos account appeared in White Noise as "Rapid Flamingo": with no
kind 0 on its relays the app makes a name up. The profile now travels
with the relay lists (the account's own signed events, unchanged), and is
sent again when it changes, checked at boot and while Chat is open.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/features/messages.js | 2 | ||||
| -rw-r--r-- | src/marmot-client.js | 40 |
2 files changed, 27 insertions, 15 deletions
diff --git a/src/features/messages.js b/src/features/messages.js index 62e2467..f7fb492 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -9702,6 +9702,8 @@ export function messagesFeature(ctx) { // Group chats ride along: the client loads with the wallet, and standing // on this screen is what makes us invitable (a KeyPackage on the relays). whiteNoise().then(async (c) => { + // a profile renamed since boot should reach White Noise's relays too (throttled inside) + if (c && wnReadied) c.announce(); if (!c || wnReadied) return; wnReadied = true; await c.load(); diff --git a/src/marmot-client.js b/src/marmot-client.js index c8878a2..7352e05 100644 --- a/src/marmot-client.js +++ b/src/marmot-client.js @@ -19,8 +19,9 @@ import { dlog } from './debug.js'; export const GROUP_RELAYS = ['wss://relay.coinos.io', 'wss://nos.lol', 'wss://relay.primal.net']; // Where White Noise looks people up. It will not invite an account whose -// relay lists (kinds 10002 and 10050) it cannot find, and it looks on its own -// relays and the purplepag.es index — not on ours. +// relay lists (kinds 10002 and 10050) it cannot find, and one whose profile +// (kind 0) it cannot find is shown under a made-up name ("Rapid Flamingo"). +// It looks on its own relays and the purplepag.es index — not on ours. const DIRECTORY_RELAYS = ['wss://relay.eu.whitenoise.chat', 'wss://relay.us.whitenoise.chat', 'wss://purplepag.es']; const DAY = 86400; @@ -35,7 +36,7 @@ export function marmotClient({ scope, pubkey, identity, on, relays = GROUP_RELAY const subs = new Map(); // route id -> { unsub, gid } const reach = new Map(); // pubkey -> { at, p } const inbox = new Map(); // gid -> queued 445 events - let dev = null, stopped = false, loaded = null, kpBusy = null, rebuilding = false; + let dev = null, stopped = false, loaded = null, kpBusy = null, rebuilding = false, announcedAt = 0; const dirty = new Set(); let flushTimer = 0, rotateTimer = 0; @@ -91,7 +92,7 @@ export function marmotClient({ scope, pubkey, identity, on, relays = GROUP_RELAY if (!kpBusy) kpBusy = ensure(opts).catch((e) => { dlog('marmot: keypackage', e); return false; }).finally(() => { kpBusy = null; // a little later: a brand-new wallet is still publishing its lists - if (dev && now() - (dev.announced || 0) > 7 * DAY) setTimeout(announce, 8000); + setTimeout(announce, 8000); }); return kpBusy; } @@ -105,18 +106,27 @@ export function marmotClient({ scope, pubkey, identity, on, relays = GROUP_RELAY return publishKeyPackage(s); } - // Put the account's relay lists where White Noise will find them. These - // are the events the account already signed, passed along unchanged — so - // no signer is asked, and a login npub's lists stay exactly as its other - // clients wrote them. Redone weekly, and until both lists exist. + // Put the account's profile and relay lists where White Noise will find + // them. These are the events the account already signed, passed along + // unchanged — so no signer is asked, and a login npub's lists stay exactly + // as its other clients wrote them. Asked for freely (at boot, whenever + // Chat is on screen) and looked at once every two minutes at most: an event goes + // out when it is new (a renamed profile) or was last sent over a week ago. async function announce() { - if (stopped || !dev) return; + if (stopped || !dev || Date.now() - announcedAt < 120_000) return; + announcedAt = Date.now(); try { - const evs = await queryOn(PROFILE_RELAYS, { kinds: [10002, 10050], authors: [pubkey] }, 3500); - const newest = (kind) => evs.filter((e) => e.kind === kind).sort((a, b) => b.created_at - a.created_at)[0]; - const lists = [newest(10002), newest(10050)]; - for (const ev of lists) if (ev) await publishOn(DIRECTORY_RELAYS, ev); - if (lists.every(Boolean)) { dev.announced = now(); await saveDev(); } + const evs = await queryOn(PROFILE_RELAYS, { kinds: [0, 10002, 10050], authors: [pubkey] }, 3500); + const sent = dev.sent || (dev.sent = {}); + let changed = false; + for (const kind of [0, 10002, 10050]) { + const ev = evs.filter((e) => e.kind === kind).sort((a, b) => b.created_at - a.created_at)[0]; + if (!ev) continue; + const last = sent[kind]; + if (last && last.id === ev.id && now() - last.at < 7 * DAY) continue; + if (await publishOn(DIRECTORY_RELAYS, ev)) { sent[kind] = { id: ev.id, at: now() }; changed = true; } + } + if (changed) await saveDev(); } catch (e) { dlog('marmot: announce', e); } } @@ -387,7 +397,7 @@ export function marmotClient({ scope, pubkey, identity, on, relays = GROUP_RELAY } return { - pubkey, groups, load, start, stop, resubscribe, ready, lookup, welcome, accept, + pubkey, groups, load, start, stop, resubscribe, ready, announce, lookup, welcome, accept, create, send, add, kick, rename, leave, forget, event: (kind, content, tags) => M.appEvent(pubkey, kind, content, tags), view: (g) => M.groupView(g.tip), |
