Skip to main content

Module reactions

Module reactions 

Source
Expand description

Canonical reaction-count codec shared between the meta adapter (which writes to the actions_data.reactions column) and the STAT native hook (which normalizes inbound STAT content.r).

Wire format: “,,,…”

  • total is the uncapped sum; the per-type list is capped to the top 5 entries, sorted DESC by count then ASC by code.
  • Empty list with total == 0 encodes as an empty string.

Functions§

decode_reaction_counts
Decodes the canonical wire format into (entries, total). Lenient: skips malformed tokens silently.
encode_reaction_counts
Encodes reactions into the canonical wire format. Sorts and truncates entries in place so callers can’t accidentally pass unsorted data. Returns “” when total == 0.
reaction_type_key
Map a reaction sub_type (e.g. “LIKE”) to its single-char wire key.