Skip to content
wiki-bot edited this page May 3, 2026 · 5 revisions

Status/Broadcast — Behavior & Safeguards

This document details how Unoapi handles Stories (Status) via Baileys and the protections added to avoid socket disconnects when large recipient lists include invalid numbers.

Inputs

  • to = "status@broadcast"
  • type is a content type supported by Baileys (text, image, video, etc.)
  • options.statusJidList = [numbers | JIDs] — the recipient list to relay after initial send

Auto-fill (image/video only):

  • If statusJidList is empty or null and type is image/video, Unoapi auto-fills from Redis contact-info keys (unoapi-contact-info::*).
  • This happens before normalization; if the list is still empty, relayMessage is skipped.

Validation & Normalization

Implemented in src/services/socket.ts inside the send() path for status@broadcast:

  • For each entry in statusJidList, call exists(raw) which resolves to a valid JID if the number has WhatsApp, or undefined otherwise.
  • Filter out all undefined (invalid numbers), log a warning with a small preview of skipped entries.
  • Optionally normalize LID JIDs to PN based on STATUS_ALLOW_LID in defaults.ts.
  • Deduplicate the final list.

If, after normalization, there are no valid recipients, the relayMessage step is skipped.

Response Augmentation

To assist monitoring and client UX, the HTTP response includes two extra fields for Status sends:

  • status_skipped: raw inputs that were removed for having no WhatsApp account.
  • status_recipients: count of valid recipients relayed.

These fields are added without breaking the Cloud API response structure (messages/contacts).

LID/PN Handling for Status

  • Recipient normalization optionally converts LID JIDs to PN when STATUS_ALLOW_LID=false; when true (default), LIDs are allowed in the recipient list.
  • Webhook payloads still prefer PN for wa_id/recipient_id whenever safely resolvable; unresolved LIDs are exposed through stable identifier fields where available instead of putting @lid in wa_id.
  • Internally, the transport may use LID to improve session availability and reduce decrypt issues; this does not change the external webhook shape.

Rationale

  • Large lists may contain numbers without WhatsApp, which previously caused Baileys errors and could drop the socket.
  • By filtering and normalizing upfront, Unoapi sends only to valid recipients and keeps the socket stable.

Clone this wiki locally