LemonChannels. Adapters. WhatsApp. Transport. MessageBuffer
(lemon_channels v0.1.0)
View Source
Message buffering and debounce logic for the WhatsApp transport.
Handles the accumulation of non-command messages within a configurable debounce window so that rapid-fire user messages are coalesced into a single inbound submission.
Functions here operate on the buffers map from GenServer state but do not
mutate state directly -- they return the updated buffers (or a full state map
update) so the caller can apply it.
Summary
Functions
Drop any pending buffer for the given inbound's scope key (e.g. when a command like /new should flush pending text).
Add an inbound message to the debounce buffer for its scope key.
Collapse the buffered messages into a single inbound and submit it.
Functions
Drop any pending buffer for the given inbound's scope key (e.g. when a command like /new should flush pending text).
Returns the updated state.
Add an inbound message to the debounce buffer for its scope key.
Returns the updated state map with buffers modified.
Collapse the buffered messages into a single inbound and submit it.
This merges multiple message entries into one text block, then delegates
to the submit_fn callback (which should be &submit_inbound_now/2).
Returns :ok (the submission side-effect is performed via the callback).