Skip to main content

Module bookmarks

Module bookmarks 

Source
Expand description

The account’s bookmarks (NIP-51, kind 10003): the notes it wants to find again.

There is one list for an account, and every new one replaces the last everywhere, as with a contact list. It names notes in two places: in its tags, for anyone to read, and in its content, which is a list of tags of the same form, as JSON, that the account encrypted to itself (NIP-44).

Avestruz keeps bookmarks in the second and nowhere else, and reads them from the second and nowhere else: what is bookmarked here is nobody else’s to know, and what a list says to anyone is not a bookmark here. The list’s tags are carried from each list to the next as they are, unread: they are for the clients that keep bookmarks there.

This is the list Amethyst shows as “Bookmarks” (its “Old Bookmarks” is kind 30001), and its private half is read and written here as it is there, so that each finds what the other left: the content is the tags as compact JSON, an e tag names a note by its id and may say after it where the note is, a new bookmark goes after the others, and a list that keeps nothing to itself has no content at all.

A bookmark is one change to the newest list, with everything else in it as it was: the other notes, and the articles, hashtags and links other clients keep there.

flowchart LR
    subgraph event["A bookmark list, kind 10003"]
        direction TB
        tags["tags: what is bookmarked for anyone to see"]
        content["content: a list of tags of the same form, as JSON, encrypted to the account (NIP-44)"]
    end
    tags -. "carried from each list to the next, unread" .-> next["The next list"]
    content -- "decrypted: takes the key" --> private["e tags: notes. a, t, r tags: what other clients keep"]
    private -- "the e tags" --> shown["The bookmarks shown here"]
    private -- "one tag more or less, re-encrypted" --> next

How a bookmark is made without losing what another client wrote meanwhile is in crate::guide::flows.

Structs§

Bookmarks
An account’s bookmarks, as its newest list has them: what the list keeps to itself.

Functions§

decode
The tags json lists, which is what a bookmark list’s content says once it is decrypted.
encode
tags as the JSON a bookmark list’s content is, before it is encrypted.
list
The bookmark list that replaces earlier, if there is one to replace: with its tags, as they are, and content for what it keeps to itself, written at now or, if earlier claims to be from later, after it: it has to be the newer of the two.
names_something_else 🔒
Whether the tag fields bookmarks something that is not a note: an article (a), a hashtag (t) or a link (r), which other clients keep in the same list.
naming 🔒
The tag that bookmarks note, which is at hint as far as is known.
note_named 🔒
The note the tag fields bookmarks, if it bookmarks one: ["e", <id>, …].
whereabouts_named 🔒
Where the tag fields, which bookmarks a note, says the note is: a relay that has it and who wrote it, each if a field after the id says (["e", <id>, <relay>, <author>], either of the two left out, as Amethyst writes it).

Type Aliases§

PrivateTags
What a list keeps to itself, once it has been decrypted: tags, as the list’s own are.