BaileysEx.Message.StubSideEffects (baileys_ex v0.1.0-alpha.8)

Copy Markdown View Source

Pure reducer that derives higher-level side-effect events from group stub messages.

Baileys' processMessage (process-message.ts, lines 513-614) translates stub message types into events like group-participants.update, groups.update, group.join-request, and chat readOnly flips. This module ports that logic as a stateless function: given a stub payload, return a list of side-effect tuples that the caller can emit through the EventEmitter.

Input

A map with the following keys:

  • :stub_type - atom stub type (e.g., :GROUP_PARTICIPANT_ADD)
  • :stub_parameters - list of string parameters (JSON-encoded participants, etc.)
  • :group_jid - the group's JID string
  • :author - the JID of the action author (participant attribute)
  • :author_pn - the PN (phone number) alternative for the author
  • :me_id - the current user's JID, used for readOnly flip detection

Output

A list of tagged tuples:

  • {:group_participants_update, payload} — participant action event
  • {:groups_update, [update]} — group metadata change event
  • {:group_join_request, payload} — join request event
  • {:chats_update, [update]} — chat read-only flip

Summary

Functions

Derive side-effect events from a group stub message payload.

Types

side_effect()

@type side_effect() ::
  {:group_participants_update, map()}
  | {:groups_update, [map()]}
  | {:group_join_request, map()}
  | {:chats_update, [map()]}

stub_input()

@type stub_input() :: %{
  stub_type: atom() | nil,
  stub_parameters: [String.t()],
  group_jid: String.t(),
  author: String.t() | nil,
  author_pn: String.t() | nil,
  me_id: String.t()
}

Functions

derive(input)

@spec derive(stub_input()) :: [side_effect()]

Derive side-effect events from a group stub message payload.

Returns a list of side-effect tuples that should be emitted via EventEmitter. Returns an empty list for unrecognized or nil stub types.