ExWapp.Message.Handler.Common (ExWapp v0.1.2)

Copy Markdown View Source

Provides shared normalization and lookup helpers for inbound node handlers.

JID, timestamp, node-attribute, chat-target, and sync metadata handling live here so individual handlers apply the same wire conventions.

Summary

Functions

chat_target(session, state)

@spec chat_target(pid() | term(), map()) :: pid() | struct() | nil

extract_group_event_timestamp(content)

@spec extract_group_event_timestamp(term()) :: integer() | nil

extract_group_subject(content)

@spec extract_group_subject(term()) :: binary() | nil

find_child_node(content, tag)

@spec find_child_node(term(), binary()) :: ExWapp.Binary.Node.t() | nil

first_non_empty(values)

@spec first_non_empty(list()) :: binary() | nil

lid_jid?(jid)

@spec lid_jid?(term()) :: boolean()

node_attr(arg1, key)

@spec node_attr(term(), binary()) :: term()

normalize_content(content)

@spec normalize_content(term()) :: binary() | nil

normalize_jid(jid)

@spec normalize_jid(term()) :: binary()

normalize_jid_with_device(jid)

@spec normalize_jid_with_device(term()) :: binary()

normalize_optional_text(jid)

@spec normalize_optional_text(term()) :: binary() | nil

parse_enc_version(version)

@spec parse_enc_version(term()) :: integer() | nil

parse_non_neg_integer(value)

@spec parse_non_neg_integer(term()) :: non_neg_integer() | nil

parse_timestamp(ts)

@spec parse_timestamp(term()) :: integer()

resolve_store_from_target(store)

@spec resolve_store_from_target(pid() | struct()) :: struct() | nil

strip_device_from_jid(jid)

@spec strip_device_from_jid(term()) :: binary()

update_stats(state, key)

@spec update_stats(map(), atom()) :: map()

upsert_chat_from_sync_attrs(target, attrs, extra_metadata \\ %{})

@spec upsert_chat_from_sync_attrs(pid() | struct(), map(), map()) :: :ok