Nostr.Event.MediaFollows (Nostr Lib v0.2.1) (event) (nip51)

View Source

Media Follows List (Kind 10020)

A multimedia (photos, short video) follow list. Similar to the main follow list (kind:3) but specifically for media-focused clients. Contains pubkeys via p tags with optional relay hints and petnames.

Defined in NIP 51 https://github.com/nostr-protocol/nips/blob/master/51.md

Summary

Functions

Creates a new media follows list (kind 10020).

Parses a kind 10020 event into a MediaFollows struct.

Types

follow_entry()

@type follow_entry() :: %{
  pubkey: binary(),
  relay: URI.t() | nil,
  petname: binary() | nil
}

t()

@type t() :: %Nostr.Event.MediaFollows{
  event: Nostr.Event.t(),
  follows: [follow_entry()]
}

Functions

create(follows, opts \\ [])

@spec create([binary() | tuple() | map()], Keyword.t()) :: t()

Creates a new media follows list (kind 10020).

Arguments

  • follows - List of follow entries (see formats below)
  • opts - Optional event arguments (pubkey, created_at)

Follow Entry Formats

Follows can be specified as:

  • "pubkey" - Just the pubkey
  • {"pubkey", "wss://relay.com"} - With relay hint
  • {"pubkey", "wss://relay.com", "petname"} - With relay and petname
  • %{pubkey: "...", relay: "...", petname: "..."} - Map format

Example

MediaFollows.create([
  "pubkey1",
  {"pubkey2", "wss://relay.com"},
  %{pubkey: "pubkey3", relay: "wss://other.com", petname: "Alice"}
])

parse(event)

@spec parse(Nostr.Event.t()) :: t()

Parses a kind 10020 event into a MediaFollows struct.