fix(message): treat poll as a first-class message type#626
Merged
Conversation
… and dashboard Native polls (#622) were persisted with type 'poll', but 'poll' was not a member of the MessageType union, so the type diverged by path: REST/DB history reported 'poll' while the live message.sent websocket/webhook event (built from the adapter type mappers) and the dashboard (via asMessageType) both coerced the same message to 'unknown'. - Add 'poll' to the engine-neutral MessageType union. - Map incoming poll messages to 'poll' in both mappers (wwjs 'poll_creation'; Baileys 'pollCreationMessage'/V2/V3). - Mirror 'poll' in the dashboard MESSAGE_TYPES and give it a stable chart color. - Assert the persisted type/body in the sendPoll service spec.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #622 (native WhatsApp polls). That change persists outgoing polls with
type: 'poll', but'poll'was never added to the engine-neutralMessageTypeunion, so the reported type diverged depending on how a client observed the same message:GET /messagesand chat history returnedtype: 'poll'(the persisted value).message.sentwebsocket/webhook event is built from the adapter type mappers, which had no poll case, so it reportedtype: 'unknown'.'poll'back to'unknown'viaasMessageType().The value degraded gracefully (the
📊 <question>body still rendered), but one message reporting two different types breaks the invariant the codebase documents inapi.ts— that persisted rows, themessage.sent/message.receivedpayloads, and the websocket all share the same neutral type values.Changes
'poll'to theMessageTypeunion (whatsapp-engine.interface.ts).'poll'in both adapters' mappers — whatsapp-web.jspoll_creation, and BaileyspollCreationMessage/pollCreationMessageV2/pollCreationMessageV3(WhatsApp bumps the content key across versions).'poll'in the dashboardMESSAGE_TYPESso it is no longer coerced tounknown, and give it a stable color in the stats chart.sendPollservice spec (it previously only checked the engine-call args, not the persistedtype/body).With this, sent and received polls report
pollconsistently across REST, the websocket, webhooks, and the dashboard.Verification
npm run lint+npm run buildclean; full Jest suite green (1927 tests, incl. updated mapper and service specs).npm run build,npm run lint, andnpm run i18n:checkall pass.