Jido.Chat.SentMessage (Jido Chat v1.0.0)

Copy Markdown View Source

Canonical sent-message handle with follow-up lifecycle operations.

Summary

Functions

Adds a reaction to the message when supported by the adapter.

Deletes the message when supported by the adapter.

Edits the message using the canonical outbound payload contract.

Builds a sent message from serialized map data.

Creates a sent-message handle from normalized adapter response data.

Removes a reaction from the message when supported by the adapter.

Returns the Zoi schema for SentMessage.

Serializes the sent message into a plain map with type marker.

Types

t()

@type t() :: %Jido.Chat.SentMessage{
  adapter: any(),
  attachments: [
    %Jido.Chat.Attachment{
      data: term(),
      duration: term(),
      filename: term(),
      height: term(),
      kind: term(),
      media_type: term(),
      metadata: term(),
      path: term(),
      size_bytes: term(),
      url: term(),
      width: term()
    }
  ],
  author:
    nil
    | nil
    | %Jido.Chat.Author{
        full_name: term(),
        is_bot: term(),
        is_me: term(),
        metadata: term(),
        user_id: term(),
        user_name: term()
      },
  default_opts: any(),
  external_room_id: nil | nil | any(),
  formatted: nil | nil | binary(),
  id: binary(),
  is_mention: boolean(),
  metadata: map(),
  raw: nil | nil | any(),
  response: %Jido.Chat.Response{
    channel_id: term(),
    channel_type: term(),
    chat_id: term(),
    date: term(),
    external_message_id: term(),
    external_room_id: term(),
    message_id: term(),
    metadata: term(),
    raw: term(),
    status: term(),
    timestamp: term()
  },
  text: nil | nil | binary(),
  thread_id: binary()
}

Functions

add_reaction(sent, emoji, opts \\ [])

@spec add_reaction(t(), String.t() | atom(), keyword()) :: :ok | {:error, term()}

Adds a reaction to the message when supported by the adapter.

delete(sent, opts \\ [])

@spec delete(
  t(),
  keyword()
) :: :ok | {:error, term()}

Deletes the message when supported by the adapter.

edit(message, input, opts \\ [])

@spec edit(t(), String.t() | Jido.Chat.Postable.t() | map(), keyword()) ::
  {:ok, t()} | {:error, term()}

Edits the message using the canonical outbound payload contract.

from_map(map)

@spec from_map(map()) :: t()

Builds a sent message from serialized map data.

new(attrs)

Creates a sent-message handle from normalized adapter response data.

remove_reaction(sent, emoji, opts \\ [])

@spec remove_reaction(t(), String.t() | atom(), keyword()) :: :ok | {:error, term()}

Removes a reaction from the message when supported by the adapter.

schema()

Returns the Zoi schema for SentMessage.

to_map(sent)

@spec to_map(t()) :: map()

Serializes the sent message into a plain map with type marker.