diff options
| author | Adam Soltys <[email protected]> | 2026-08-18 12:06:04 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-18 12:06:04 -0700 |
| commit | a0374566a5c69d87e5a156f5fabecf5b9b45d6f9 (patch) | |
| tree | cf87f4584724e9149c8ae1075d28007a2a9d203b /src/dm.js | |
| parent | 3d80fef6aeab03795c4257ab8c4f27113d7e9022 (diff) | |
| download | coinosv3-a0374566a5c69d87e5a156f5fabecf5b9b45d6f9.tar.gz coinosv3-a0374566a5c69d87e5a156f5fabecf5b9b45d6f9.zip | |
A message sends the instant you let go of it: the rumor hashes synchronously onto the screen as a dimmed bubble, crypto and relays catch up in the background, and one small tick marks the moment a relay takes it
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012u4oe1KPx9faCsDBLfZYqi
Diffstat (limited to 'src/dm.js')
| -rw-r--r-- | src/dm.js | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -47,18 +47,26 @@ export async function wrapDM(skOrSigner, receiverPk, rumor, extraTags = []) { ); } -// A DM to a peer: the kind 14 rumor (unsigned, true timestamp) plus wraps for -// the recipient and for the sender's own inbox (the sent-copy). -export async function makeDM(skOrSigner, peerPk, text) { - const signer = asSigner(skOrSigner); +// The kind 14 rumor alone, id included — synchronous, so a sender can put +// the message on screen before any signing or encryption has run. Wrapping +// the same rumor later yields the same id, so the sent-copy echo dedupes. +export function makeDMRumor(senderPk, peerPk, text) { const rumor = { kind: 14, - pubkey: signer.pubkey, + pubkey: senderPk, content: text, tags: [['p', peerPk]], created_at: now(), }; rumor.id = getEventHash(rumor); + return rumor; +} + +// A DM to a peer: the kind 14 rumor (unsigned, true timestamp) plus wraps for +// the recipient and for the sender's own inbox (the sent-copy). +export async function makeDM(skOrSigner, peerPk, text) { + const signer = asSigner(skOrSigner); + const rumor = makeDMRumor(signer.pubkey, peerPk, text); return { rumor, toPeer: await wrapDM(signer, peerPk, rumor), |
