Skip to main content

Module kept_drafts

Module kept_drafts 

Source
Expand description

Drafts as events (NIP-37): what is written and not published, as the relay Avestruz runs itself keeps it.

A draft is kept as a draft wrap (kind 31234): an addressable event the account signs, whose content is the note the draft would be, unsigned, as JSON, encrypted to the account itself (NIP-44). Its d tag says which draft it is, so that a later one replaces it, and its k tag what kind of event it wraps. A wrap with no content is a draft that was done with: published, or cleared.

There is one draft for each thing that can be written to, as in crate::drafts, and the d tag is which: a note of its own, a reply to a note, a quote of one.

flowchart TD
    text["What was written"] --> note["The note it would be: kind 1, unsigned, as JSON"]
    note -- "encrypted to the account (NIP-44)" --> content
    subgraph wrap["A draft wrap, kind 31234, signed by the account"]
        direction TB
        d["d: which draft it is"]
        k["k: 1, the kind it wraps"]
        e["e: the note answered or quoted, if any"]
        content["content: the encrypted note, or nothing for a draft done with"]
    end
    wrap --> relay["The relay Avestruz runs itself, and no other"]
Written tod tag
A note of its ownavestruz:note
A reply to a noteavestruz:reply: and the note’s id
A quote of a noteavestruz:quote: and the note’s id

Wraps with any other d tag are another client’s drafts, and are left alone.

Constants§

DRAFT_KIND
The kind of a draft wrap.
NOTE 🔒
What the d tag of a draft says, by what the draft is of: a note of its own; or, before the id of the note it is about, a reply or a quote.
QUOTE 🔒
REPLY 🔒

Functions§

identifier
What the d tag of the draft for target says.
kept
What the draft wrap event is a draft of, and its content, which is empty when the draft is done with. None if it is no draft wrap, or not one of this client’s.
said_of
What the draft that json is says of the files it links to: its imeta tags. None if it is no event, or has none.
target_of
What the draft whose d tag says identifier is a draft of, if it is one of this client’s.
text_of
The text of the draft that json is, which is what a draft wrap’s content says once it is decrypted. None if it is no event, or says nothing.
wrap
The draft wrap for target, with content for what it wraps: encrypted, or nothing at all for a draft that is done with. Written at now or, if earlier, the wrap it replaces, claims to be from later, after it: it has to be the newer of the two.
written
What a draft wrap’s content is before it is encrypted: the note text would be if account published it at now, unsigned, as JSON. Of its tags it has those in said: what it says of the files it links to (NIP-92), which nothing but having sent them tells.