diff options
| author | Adam Soltys <[email protected]> | 2026-11-22 09:27:48 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-11-22 09:27:48 -0700 |
| commit | 9d73d5deb959712dd6007d639f278a8db9e6f2aa (patch) | |
| tree | 5759647cf20fa11393aa282260087f9cebe3c266 | |
| parent | 21fa1db9ef8cdc2923a50a3adbe079a5169c7299 (diff) | |
| download | coinosv3-9d73d5deb959712dd6007d639f278a8db9e6f2aa.tar.gz coinosv3-9d73d5deb959712dd6007d639f278a8db9e6f2aa.zip | |
A boost carries the signed post, so it is not thrown away. "I refreshed my phone but still not seeing it in my following feed" (Adam, 2026-11-22, after 21fa1db made his own boosts show). His boost of pnk's post (kind 6 b412fa11) held a copy of the post with no signature: the row he tapped had been painted from the saved feed, which keeps posts without their signature, and the boost embedded that object as it was. A repost whose copy does not verify is left out by this app and by every client that checks, so the boost showed nowhere. Before boosting, a post that does not verify in memory is now fetched whole by id from the post's relays and the note relays, and only the signed fields go into the boost; when the signed post cannot be found the boost is not sent and the failure is said. own-boost-feed-test checks that both boosts it publishes carry a post that verifies; feed-repost passes.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VMan6Upic5L6MMJzkTn8zg
| -rw-r--r-- | src/features/messages.js | 12 | ||||
| -rw-r--r-- | tools/own-boost-feed-test.js | 15 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/features/messages.js b/src/features/messages.js index 03fabee..5ec55c7 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -11822,8 +11822,18 @@ export function messagesFeature(ctx) { if (iBoosted(ev.id)) { toast(t('postBoostedAlready')); return; } const id = await requireIdentity(); const relays = await noteRelaysFor(ev); + // The copy inside must carry its author's signature, or every client + // that checks it (this one too) throws the boost away. A post painted + // from the saved feed was stored without one: fetch it whole first. + let whole = ev.sig && verifyEvent({ ...ev }) ? ev : null; + if (!whole) { + const got = await queryOn([...new Set([...relays, ...NOTE_RELAYS])], { ids: [ev.id] }, 4000).catch(() => []); + whole = got.find((e) => e.id === ev.id && e.sig && verifyEvent(e)) || null; + } + if (!whole) { toast(t('msgSendFailed')); return; } + whole = { id: whole.id, pubkey: whole.pubkey, created_at: whole.created_at, kind: whole.kind, tags: whole.tags, content: whole.content, sig: whole.sig }; const partial = { - kind: 6, content: JSON.stringify(ev), created_at: Math.floor(Date.now() / 1000), + kind: 6, content: JSON.stringify(whole), created_at: Math.floor(Date.now() / 1000), tags: [['e', ev.id, relays[0] || '', 'mention'], ['p', ev.pubkey], CLIENT_TAG], }; const evt = id.signer instanceof Uint8Array ? finalizeEvent(partial, id.signer) : await id.signer.signEvent(partial); diff --git a/tools/own-boost-feed-test.js b/tools/own-boost-feed-test.js index e5e3440..ab2a88f 100644 --- a/tools/own-boost-feed-test.js +++ b/tools/own-boost-feed-test.js @@ -7,7 +7,7 @@ // Run: bun tools/own-boost-feed-test.js import puppeteer, { seedWords, skipSeedCheck } from './puppeteer.js'; import { cacheKeyFor } from '../src/wallet.js'; -import { generateSecretKey, getPublicKey, finalizeEvent } from 'nostr-tools/pure'; +import { generateSecretKey, getPublicKey, finalizeEvent, verifyEvent } from 'nostr-tools/pure'; import { privateKeyFromSeedWords } from 'nostr-tools/nip06'; import { buildHtml } from '../build.js'; const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); @@ -78,7 +78,8 @@ try { for (let i = 0; i < 40; i++) { r = await rows(); top = r[0]; if (top && top.paff && top.reposted) break; await sleep(250); } check('the boost is at the top of my feed, under "… reposted"', !!top && top.paff && top.reposted, JSON.stringify(r.slice(0, 3))); check('the row I tapped is still where it was', r.filter((x) => x.paff).length === 2); - check('the boost was published', await page.evaluate(() => JSON.parse(localStorage.getItem('__pub') || '[]').length === 1)); + const first = await page.evaluate(() => JSON.parse(localStorage.getItem('__pub') || '[]')); + check('the boost was published, with the signed post inside', first.length === 1 && verifyEvent(JSON.parse(first[0].content))); await sleep(1500); // the feed cache is written await page.reload({ waitUntil: 'domcontentloaded' }); await waitText('receive', 20000); @@ -88,6 +89,13 @@ try { r = await rows(); const both = (r) => !!r[0] && r[0].paff && r[0].reposted && r.filter((x) => x.paff).length === 2 && r.filter((x) => x.paff && x.reposted).length === 1 && r[r.length - 1].paff && !r[r.length - 1].reposted; check('after a reload: my boost first (the newest), the post itself still in its place', both(r), JSON.stringify(r.map((x) => [+x.paff, +x.reposted]))); + // a post painted from the saved feed has no signature in memory: its boost must still carry one + const before = await page.evaluate(() => JSON.parse(localStorage.getItem('__pub') || '[]').length); + const cachedTap = await page.evaluate(() => { const row = [...document.querySelectorAll('.notes-feed > .row[data-key]')].find((n) => n.textContent.includes('filler post number 3 ')); const b = row && [...row.querySelectorAll('.note-acts button')].find((x) => /boost/i.test(x.getAttribute('aria-label') || x.title || '')); if (b) { b.click(); return true; } return false; }); + let second = null; + for (let i = 0; i < 40 && !second; i++) { await sleep(250); second = await page.evaluate((n) => JSON.parse(localStorage.getItem('__pub') || '[]')[n] || null, before); } + const inner = second && JSON.parse(second.content); + check('a boost of a post from the saved feed carries the signed post', cachedTap && !!inner && !!inner.sig && verifyEvent(inner), JSON.stringify(inner && Object.keys(inner))); // a second device: nothing cached, the post and the boost both come from relays await page.evaluate(() => { for (const k of Object.keys(localStorage)) if (/feed-cache|feedcache|:feed:|notes/i.test(k)) localStorage.removeItem(k); }); await page.evaluate(async () => { if (indexedDB.databases) for (const d of await indexedDB.databases()) if (/feed|note/i.test(d.name || '')) indexedDB.deleteDatabase(d.name); }); @@ -97,7 +105,8 @@ try { await waitText('Running a PAFF server', 30000); await sleep(4000); r = await rows(); - check('with no cache: the same two rows', both(r), JSON.stringify(r.map((x) => [+x.paff, +x.reposted]))); + const p = r.filter((x) => x.paff); + check('with no cache: my boosts lead in time order, the post itself still in its place', r[0].reposted && r[1].reposted && r[1].paff && p.length === 2 && !p[1].reposted && r.filter((x) => x.reposted).length === 2, JSON.stringify(r.map((x) => [+x.paff, +x.reposted]))); check('no page errors', errs.length === 0, errs.slice(0, 2).join(' | ')); } finally { await browser.close(); server.stop(true); } console.log(ok ? '\n✅ my own boost shows in my feed' : '\n❌ failed'); |
