Liking cljdoc? Tell your friends :D

dk.simongray.podcast.comments.nostr

Threads of comments on Nostr, read from relays.

A thread has one of two kinds of root:

  • a note, which podcast:socialInteract names by a nostr: URI of NIP-21 or by a name of NIP-19, such as nevent1… or note1…
  • the episode or the show itself, by the id that NIP-73 gives it, such as podcast:item:guid:…

No post is the root of the thread of an episode or a show, so its root is a comment without content.

The comments are the text notes of kind 1, with the replies of NIP-10, and the comments of kind 1111 of NIP-22. The authors are the events of kind 0 of NIP-01, and an event of kind 5 of NIP-09 deletes a comment of its author.

A relay can send anything. So a reading keeps only the events whose signatures verify and that pass a filter of the request. A thread counts the events that it left out, and the report tells the count.

The relays are those that the root names, and then the :relays of the options, or the default ones. Each relay gets the same questions, and an event that two relays give is one comment.

Threads of comments on Nostr, read from relays.

A thread has one of two kinds of root:

- a note, which podcast:socialInteract names by a nostr: URI of NIP-21
  or by a name of NIP-19, such as nevent1… or note1…
- the episode or the show itself, by the id that NIP-73 gives it, such
  as podcast:item:guid:…

No post is the root of the thread of an episode or a show, so its root
is a comment without content.

The comments are the text notes of kind 1, with the replies of NIP-10,
and the comments of kind 1111 of NIP-22. The authors are the events of
kind 0 of NIP-01, and an event of kind 5 of NIP-09 deletes a comment of
its author.

A relay can send anything. So a reading keeps only the events whose
signatures verify and that pass a filter of the request. A thread
counts the events that it left out, and the report tells the count.

The relays are those that the root names, and then the :relays of the
options, or the default ones. Each relay gets the same questions, and
an event that two relays give is one comment.
raw docstring

aboutclj/s

(about feed)
(about feed item)
(about feed item {:keys [url] :as opts})

The unread thread of the comments about feed, or about its item, by the id that NIP-73 gives a show and an episode, with opts. It's nil for a show or an episode without a guid.

The id of a show is podcast:guid: and its podcast:guid, and the :url of opts is the URL of a feed that declares none. The id of an episode is podcast:item:guid: and the guid of the item.

Such a thread isn't the thread that the podcaster names. When a podcast:socialInteract has the protocol disabled, the podcaster wants no public comments shown.

The unread thread of the comments about `feed`, or about its `item`, by
the id that NIP-73 gives a show and an episode, with `opts`. It's nil
for a show or an episode without a guid.

The id of a show is podcast:guid: and its podcast:guid, and the :url of
`opts` is the URL of a feed that declares none. The id of an episode is
podcast:item:guid: and the guid of the item.

Such a thread isn't the thread that the podcaster names. When a
podcast:socialInteract has the protocol disabled, the podcaster wants
no public comments shown.
sourceraw docstring

batch-sizeclj/s

The most ids or public keys in one filter of a request. The option :batch-size gives another number.

The most ids or public keys in one filter of a request. The option
:batch-size gives another number.
sourceraw docstring

comment-eventclj/s

(comment-event thread content)
(comment-event {:keys [uri] :as thread}
               content
               {:keys [kind url] :or {kind 1111} :as opts})

The event of a new comment with the text content at the root of thread, with the opts below, to post with post!. It has no time and no signature yet.

On a show or an episode, it's a comment of kind 1111 of NIP-22 with the id of NIP-73, or with :kind 1 a note with the id in an i tag, as the app Fountain writes it. On a note, it's a reply of kind 1 of NIP-10.

  • :kind, 1111 or 1, for a thread about a show or an episode
  • :url, the web page of the episode, a hint for other apps
The event of a new comment with the text `content` at the root of
`thread`, with the `opts` below, to post with post!. It has no time and
no signature yet.

On a show or an episode, it's a comment of kind 1111 of NIP-22 with the
id of NIP-73, or with :kind 1 a note with the id in an i tag, as the app
Fountain writes it. On a note, it's a reply of kind 1 of NIP-10.

- :kind, 1111 or 1, for a thread about a show or an episode
- :url, the web page of the episode, a hint for other apps
sourceraw docstring

delete-eventclj/s

(delete-event thread id)
(delete-event thread id reason)

The event that asks the relays to delete the comment id of thread, with the text reason for its readers, to post with post! and the key of its author. It's nil when the thread has no event of that comment.

The event that asks the relays to delete the comment `id` of `thread`,
with the text `reason` for its readers, to post with post! and the key
of its author. It's nil when the thread has no event of that comment.
sourceraw docstring

hiccupclj/s

(hiccup event)
(hiccup event {:keys [names] :as opts})

The content of event as Hiccup by opts: a paragraph for each group of lines, in the order of the text. The result is a sequence of nodes to put inside a parent element.

NIP-10 and NIP-22 give a note plain text, and NIP-27 tells what its nostr: URIs are. In the Hiccup:

  • A web URL is a link.
  • A mention of a profile is an at sign and the name of the profile from the :names of opts, a map from public keys to names. Without a name, it's the start and the end of the npub1… name.
  • A reference to an event is the start and the end of its name.
  • A hashtag is the word with its number sign.

The :link-fn of opts is a function of a part. It gives the URL that a mention, a reference or a hashtag links to, or nil for no link. No web page is named for them, since you choose the web app or the scheme that shows them.

Some lines say again what the tags of the event tell. Such a line has only the web page of the episode or the show that the note is about, or only the media of an attachment. It's left out, and so is a reference to the receipt of a payment.

The content of `event` as Hiccup by `opts`: a paragraph for each group
of lines, in the order of the text. The result is a sequence of nodes
to put inside a parent element.

NIP-10 and NIP-22 give a note plain text, and NIP-27 tells what its
nostr: URIs are. In the Hiccup:

- A web URL is a link.
- A mention of a profile is an at sign and the name of the profile from
  the :names of `opts`, a map from public keys to names. Without a
  name, it's the start and the end of the npub1… name.
- A reference to an event is the start and the end of its name.
- A hashtag is the word with its number sign.

The :link-fn of `opts` is a function of a part. It gives the URL that a
mention, a reference or a hashtag links to, or nil for no link. No web
page is named for them, since you choose the web app or the scheme that
shows them.

Some lines say again what the tags of the event tell. Such a line has
only the web page of the episode or the show that the note is about, or
only the media of an attachment. It's left out, and so is a reference
to the receipt of a payment.
sourceraw docstring

namesclj/s

(names thread)

The names of the authors that thread has, by public key, e.g. for the :names of the options.

The names of the authors that `thread` has, by public key, e.g. for the
:names of the options.
sourceraw docstring

partsclj/s

(parts event)
(parts event {:keys [names] :as opts})

The parts of the content of event as a reader sees it, in their order, with the names of opts. Each part is a map with its :type and the :text that the content shows for it:

{:type :text :text "Is this "}
{:type :mention :text "@Ann" :id "3bf0…" :public-key "3bf0…"
 :uri "nostr:npub1…"}
{:type :reference :text "nevent1qqs9…m9d82" :target {…}
 :uri "nostr:nevent1…"}
{:type :link :text "https://example.org/" :url "https://example.org/"}
{:type :hashtag :text "#podcast" :tag "podcast"}

The text of a mention is an at sign and the name of the profile, from the :names of opts, a map from public keys to names. Without a name, it's the start and the end of the npub1… name. The text of a reference is the start and the end of its name. The lines that say again what the tags of the event tell aren't there. A blank line is between two paragraphs.

The parts of the content of `event` as a reader sees it, in their
order, with the names of `opts`. Each part is a map with its :type and
the :text that the content shows for it:

    {:type :text :text "Is this "}
    {:type :mention :text "@Ann" :id "3bf0…" :public-key "3bf0…"
     :uri "nostr:npub1…"}
    {:type :reference :text "nevent1qqs9…m9d82" :target {…}
     :uri "nostr:nevent1…"}
    {:type :link :text "https://example.org/" :url "https://example.org/"}
    {:type :hashtag :text "#podcast" :tag "podcast"}

The text of a mention is an at sign and the name of the profile, from
the :names of `opts`, a map from public keys to names. Without a name,
it's the start and the end of the npub1… name. The text of a reference
is the start and the end of its name. The lines that say again what the
tags of the event tell aren't there. A blank line is between two
paragraphs.
sourceraw docstring

post!clj/s

(post! thread event signer)
(post! thread
       event
       signer
       {:keys [send allow-pred now-fn]
        :or {send nostr/send! allow-pred nostr/public? now-fn time/now}
        :as opts})

Sign event with signer, and give it to the relays of thread with opts. It gives the signed event and what each relay did with it, or a map with a diagnostic under :error. On the JVM it gives the result, and in ClojureScript a promise of it.

{:event  {…}
 :relays {"wss://relay.example" {:accepted? true}
          "wss://other.example" {:refused "blocked: …"}}}

The event gets the time of now, unless it has one. The relays are those that the root of the thread names, and then the :relays of opts, or the default ones, and each gets the event at once. A result has :nostr/not-published under :error when no relay took the event, and the error of the signer when it didn't sign. The opts are these:

  • :relays, in place of the default relays
  • :send, a function that sends a request map to a relay, in place of nostr/send!
  • :allow-pred, a predicate of the URL of a relay, nostr/public? by default
  • :timeout-seconds, for each relay
  • :now-fn, a function that gives the instant of now, the clock by default
Sign `event` with `signer`, and give it to the relays of `thread` with
`opts`. It gives the signed event and what each relay did with it, or a
map with a diagnostic under :error. On the JVM it gives the result, and
in ClojureScript a promise of it.

    {:event  {…}
     :relays {"wss://relay.example" {:accepted? true}
              "wss://other.example" {:refused "blocked: …"}}}

The event gets the time of now, unless it has one. The relays are those
that the root of the thread names, and then the :relays of `opts`, or
the default ones, and each gets the event at once. A result has
:nostr/not-published under :error when no relay took the event, and the
error of the signer when it didn't sign. The `opts` are these:

- :relays, in place of the default relays
- :send, a function that sends a request map to a relay, in place of
  nostr/send!
- :allow-pred, a predicate of the URL of a relay, nostr/public? by
  default
- :timeout-seconds, for each relay
- :now-fn, a function that gives the instant of now, the clock by default
sourceraw docstring

reaction-eventclj/s

(reaction-event thread id)
(reaction-event {:keys [uri] :as thread} id content)

The event of the reaction content to the comment id of thread, to post with post!. A + is a like, the reaction without content. It's nil when the thread has no event of that comment.

A reaction to the show or the episode at the root of a thread about one is of kind 17, with its id of NIP-73.

The event of the reaction `content` to the comment `id` of `thread`, to
post with post!. A + is a like, the reaction without `content`. It's nil
when the thread has no event of that comment.

A reaction to the show or the episode at the root of a thread about one
is of kind 17, with its id of NIP-73.
sourceraw docstring

readable?clj/s

(readable? interact opts)

Whether the thread of interact can be read with opts. Its URI must name a note or an id of NIP-73, and there must be a relay to ask.

Whether the thread of `interact` can be read with `opts`. Its URI must
name a note or an id of NIP-73, and there must be a relay to ask.
sourceraw docstring

receiptsclj/s

(receipts event)

The ids of the receipts of payments that the content of event names. A note that came with a payment names the receipt, as the app Fountain writes a boost. The name of the receipt tells its kind, 9735 of NIP-57.

The ids of the receipts of payments that the content of `event` names.
A note that came with a payment names the receipt, as the app Fountain
writes a boost. The name of the receipt tells its kind, 9735 of NIP-57.
sourceraw docstring

relaysclj/s

The relays that podcast-clj asks for comments when neither the root of a thread nor the options name a relay. The page doc/services.md tells when each relay answered.

The relays that podcast-clj asks for comments when neither the root of
a thread nor the options name a relay. The page doc/services.md tells
when each relay answered.
sourceraw docstring

reply-eventclj/s

(reply-event {:keys [root] :as thread} id content)

The event of the text content that replies to the comment id of thread, which a reading gave, to post with post!. It has no time and no signature yet, and it's nil when the thread has no event of that comment.

A reply to a comment of kind 1111 is one too, with the root scope of its parent, as NIP-22 defines it. A reply to a note of kind 1 is a note, with the e tags of NIP-10 that name the root of its thread and the note. A reply to the root of the thread is comment-event.

The event of the text `content` that replies to the comment `id` of
`thread`, which a reading gave, to post with post!. It has no time and
no signature yet, and it's nil when the thread has no event of that
comment.

A reply to a comment of kind 1111 is one too, with the root scope of its
parent, as NIP-22 defines it. A reply to a note of kind 1 is a note,
with the e tags of NIP-10 that name the root of its thread and the note.
A reply to the root of the thread is comment-event.
sourceraw docstring

requestsclj/s

(requests
  {:keys [uri comments] :dk.simongray.podcast.comments/keys [held] :as thread}
  opts
  ask-pred)

The requests that the Nostr thread needs next with opts, of those whose URLs ask-pred takes, with one request for each relay at most.

A relay gets the question for the root first. Then it gets the questions for the replies to the comments that the thread has, those nearest the root first. Then it gets the questions for their authors, and for the profiles that they mention. The requests ask for no more comments than the :max-comments of opts allows, counted from the start of the reading.

Each request is a request map with the :url of a relay and the :filters of NIP-01.

The requests that the Nostr `thread` needs next with `opts`, of those
whose URLs `ask-pred` takes, with one request for each relay at most.

A relay gets the question for the root first. Then it gets the
questions for the replies to the comments that the thread has, those
nearest the root first. Then it gets the questions for their authors,
and for the profiles that they mention. The requests ask for no more
comments than the :max-comments of `opts` allows, counted from the
start of the reading.

Each request is a request map with the :url of a relay and the :filters
of NIP-01.
sourceraw docstring

resumedclj/s

(resumed thread)

The Nostr thread as a new reading of it starts: unread again where a failure that can pass with time stopped the last reading. This is the question that a relay didn't answer.

The Nostr `thread` as a new reading of it starts: unread again where a
failure that can pass with time stopped the last reading. This is the
question that a relay didn't answer.
sourceraw docstring

with-exchangesclj/s

(with-exchanges {:keys [uri authors] :as thread} [exchange :as exchanges] at)

The Nostr thread with the exchanges of one of its requests read into it at at. There's one exchange for the request, and its response is the map that nostr/send! gives, or a map of the :error.

The thread notes what each relay answered, so that a relay gets each question once. A relay that didn't answer keeps the problem of it, and gets the question again when the problem is :retry?.

The name of a profile comes after the comment that mentions it. The content of the comment then gets the name.

The Nostr `thread` with the `exchanges` of one of its requests read
into it at `at`. There's one exchange for the request, and its response
is the map that nostr/send! gives, or a map of the :error.

The thread notes what each relay answered, so that a relay gets each
question once. A relay that didn't answer keeps the problem of it, and
gets the question again when the problem is :retry?.

The name of a profile comes after the comment that mentions it. The
content of the comment then gets the name.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close