View Source Nex.Messages.Event (Nex v0.1.0)

Nostr Event schema.

See NIP-01.

Link to this section Summary

Types

t()

Event

Functions

Calculates the ID for the given event. Returns a hex-encoded ID.

Returns a changeset from the given params.

Returns the ID preimage for the given event. Clients will sign this value.

Guard returning true if the given kind is of any ephemeral event.

Guard returning true if the given kind is of any replaceable event.

Returns a changeset from the given params.

Link to this section Types

@type t() :: %Nex.Messages.Event{
  __meta__: term(),
  content: String.t(),
  created_at: integer(),
  db_tags: term(),
  delegator: String.t(),
  expires_at: integer(),
  id: String.t(),
  inserted_at: term(),
  kind: integer(),
  nid: term(),
  pubkey: String.t(),
  replace_key: String.t(),
  sig: String.t(),
  tags: [Nex.Messages.Tag.t()]
}

Event

Link to this section Functions

@spec calc_id(Ecto.Schema.t()) :: String.t()

Calculates the ID for the given event. Returns a hex-encoded ID.

Link to this function

changeset(event, params \\ %{})

View Source
@spec changeset(Ecto.Schema.t(), map()) :: Ecto.Changeset.t()

Returns a changeset from the given params.

This base changeset validates the presents and format of all fields, but does not verify the event ID or signature.

@spec id_preimage(Ecto.Schema.t()) :: String.t()

Returns the ID preimage for the given event. Clients will sign this value.

Link to this macro

is_ephemeral_kind(kind)

View Source (macro)

Guard returning true if the given kind is of any ephemeral event.

Link to this macro

is_replacable_kind(kind)

View Source (macro)

Guard returning true if the given kind is of any replaceable event.

Link to this function

verify_changeset(event, params \\ %{})

View Source
@spec verify_changeset(Ecto.Schema.t(), map()) :: Ecto.Changeset.t()

Returns a changeset from the given params.

As f:changeset/2 but also verifies the event ID and signature.