ExWapp.Session.Worker.SendRecovery (ExWapp v0.1.2)

Copy Markdown View Source

What the session does when a send does not land.

Three recoveries live here, in the order the server pushes the session through them:

  • resend — the payload of every outgoing message is remembered briefly so it can be sent again without asking the caller to rebuild it
  • repair — a rejected send usually means the peer's Signal session is stale, so it is dropped and renegotiated before the resend goes out
  • placeholder — when a message arrives that this device cannot decrypt at all, the primary device is asked to send it again

Retries run in worker processes started from here; like everything else called by the session, this code runs inside the session process, so those workers are started by it and report back to its mailbox.

A rejection is only reported to the caller once no recovery is left: reporting early would surface an error for a message that is about to be resent successfully.

Summary

Functions

do_send_text_worker(session_pid, state, jid, text, opts)

maybe_retry_outgoing_message(state, jid, message_id, retry_meta)

maybe_start_placeholder_resend_request(state, chat_jid, sender_jid, message_id, metadata)

normalize_outbound_text(text)

normalize_retry_participant(participant)

register_send_worker(state, worker, mon, label, from \\ nil)

remember_outgoing_retry_payload(state, jid, text, message_id)

repair_session_and_retry(state, message_id, jid, ack)

@spec repair_session_and_retry(map(), String.t(), String.t(), ExWapp.Error.Ack.t()) ::
  map()
@spec repair_session_and_retry(
  ExWapp.Session.Worker.t(),
  String.t(),
  String.t(),
  ExWapp.Error.Ack.t()
) ::
  ExWapp.Session.Worker.t()

run_session_repair(state, message_id, jid, ack, attempts, max_attempts)

@spec run_session_repair(
  map(),
  String.t(),
  String.t(),
  ExWapp.Error.Ack.t(),
  non_neg_integer(),
  non_neg_integer()
) :: map()

session_repair_attempts(state, message_id)

@spec session_repair_attempts(map(), String.t()) :: non_neg_integer()
@spec session_repair_attempts(ExWapp.Session.Worker.t(), String.t()) ::
  non_neg_integer()

start_send_worker(arg1, label, fun)