Skip to main content

Module compose

Module compose 

Source
Expand description

What someone wrote, made into an event ready to be signed: a note of its own, a reply to another, or a note that quotes another.

The text goes out as it was written. The tags say what a relay or another client can’t be expected to read out of the text: which conversation a reply belongs to and whom it answers, who is mentioned, which notes are quoted, and the hashtags.

What a reply is depends on what it answers. An answer to a text note is a text note (NIP-10). An answer to anything else — a comment, or what comments are about — is a comment (NIP-22): the two don’t mix.

A quote is a note with the address of another in its text (NIP-18), which quote puts under what was written. Nothing else sets it apart: whatever names a note in its text quotes it.

flowchart TD
    written["What was written, and what it was written to"] --> target{"Written to?"}
    target -->|"nothing"| note["Kind 1, with no reply tags"]
    target -->|"nothing, about a note"| quoted["Kind 1. The note's address goes under the text"]
    target -->|"a note"| parent{"What kind is the note answered?"}
    parent -->|"a text note, kind 1"| reply["Kind 1. e tags: the root, and the note answered. p tags: its author, and everyone it spoke to"]
    parent -->|"anything else"| comment["Kind 1111. What the comments are about, in capitals, then the note answered"]
    note --> text
    quoted --> text
    reply --> text
    comment --> text["Then what the text calls for: a p for each mention, a t for each hashtag, a q for each note quoted"]

One kind of tag is not read out of the text, since the text doesn’t say it: what the note says of a file it links to that was sent to a media server from here (imeta, NIP-92; see crate::nostr::blossom::imeta). Those are added to what build made, by whoever publishes it.

Everything here is pure: text and an event in, an unsigned event out. Signing and sending are elsewhere (see crate::guide::flows).

Enums§

Target
What is written to.

Functions§

build
text as an event of author’s, yet to be signed: a note; a reply to parent, if that is a text note; or a comment on parent, if it is anything else. A note that quotes another is a note, whatever it quotes. A tag the reply already carries is not added again for the text’s sake.
comment_tags 🔒
The tags that make a comment an answer to parent, which is not a text note (NIP-22).
content_tags 🔒
The tags the text itself calls for: a p for everyone mentioned, a t for every hashtag, and a q for every note quoted, with a p for who wrote it, as far as its address says. Each once; author, who writes the text, is not told of quoting themselves.
quote
What a quote of quoted says, when text was written about it: the text, and under it the note’s address, where other clients show the note. The address says who wrote the note and what kind of event it is, so that it can be found by those who don’t have it. With nothing written, the address is all there is.
reply_tags 🔒
The tags that make a note a reply to parent, written by author.