BaileysEx.Message.Sender (baileys_ex v0.1.0-alpha.7)

Copy Markdown View Source

Message send pipeline.

Summary

Functions

Sends a generic content map to the specified JID, converting maps to WAProto messages.

Serializes, encrypts, and transmits a pre-constructed WAProto message to a specific JID.

Uploads a new status update to all valid contacts via status broadcast channel.

Types

context()

@type context() :: %{
  :signal_repository => BaileysEx.Signal.Repository.t(),
  :signal_store => BaileysEx.Signal.Store.t(),
  :me_id => String.t(),
  optional(:device_identity) => binary(),
  optional(:enable_recent_message_cache) => boolean(),
  optional(:me_lid) => String.t(),
  optional(:store_ref) => BaileysEx.Connection.Store.Ref.t(),
  optional(:query_fun) => (BaileysEx.BinaryNode.t() ->
                             {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}),
  optional(:send_node_fun) => (BaileysEx.BinaryNode.t() ->
                                 :ok | {:error, term()}),
  optional(:socket) => GenServer.server(),
  optional(:cached_group_metadata) => (String.t() -> {:ok, map()} | nil),
  optional(:group_metadata_fun) => (String.t() ->
                                      {:ok, map()} | {:error, term()})
}

proto_message()

@type proto_message() :: struct()

send_result()

@type send_result() :: %{
  id: String.t(),
  jid: BaileysEx.JID.t(),
  message: proto_message(),
  timestamp: integer()
}

Functions

send(context, jid, content, opts \\ [])

@spec send(context(), BaileysEx.JID.t(), map(), keyword()) ::
  {:ok, send_result(), context()} | {:error, term()}

Sends a generic content map to the specified JID, converting maps to WAProto messages.

send_proto(context, jid, proto_message, opts \\ [])

@spec send_proto(context(), BaileysEx.JID.t(), proto_message(), keyword()) ::
  {:ok, send_result(), context()} | {:error, term()}

Serializes, encrypts, and transmits a pre-constructed WAProto message to a specific JID.

send_status(context, content, opts \\ [])

@spec send_status(context(), map(), keyword()) ::
  {:ok, map(), context()} | {:error, term()}

Uploads a new status update to all valid contacts via status broadcast channel.