Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(sdk): declare the chat-history fields the endpoint returns
Yudhi Armyndharis89e1f6e6decc
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4e4319ab3..fa7533a5d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Turkish (`tr`) dashboard translation. Thanks @codedByCan.+### Fixed++- The JavaScript, Python, Go and Java SDKs omitted `contact`, `call` and `ephemeralDuration` from their chat-history message type, so a typed client had to cast to read three fields the endpoint returns; all four now mirror the engine payload, and a type-level contract assertion in the JavaScript SDK fails the build if that type and the engine interface drift apart again.+### Documentation- `RESOLVE_LID_TO_PHONE` was documented nowhere outside `.env.example`, so an operator receiving `@lid` senders had no path to the flag that resolves them; the event catalog now carries the `senderPhone` opt-in callout, the contact-phone endpoint points back to it, and the troubleshooting FAQ covers the symptom.diff --git a/sdk/go/types_message.go b/sdk/go/types_message.goindex d7a2c6116..7d962ce62 100644--- a/sdk/go/types_message.go+++ b/sdk/go/types_message.go@@ -217,15 +217,45 @@ type ChatHistoryMessage struct {IsGroup bool `json:"isGroup"`IsStatusBroadcast bool `json:"isStatusBroadcast"`Kind string `json:"kind"`+ EphemeralDuration int `json:"ephemeralDuration,omitempty"`Author string `json:"author,omitempty"`MentionedIDs []string `json:"mentionedIds,omitempty"`+ Call *MessageCall `json:"call,omitempty"`IsLidSender bool `json:"isLidSender,omitempty"`SenderPhone *string `json:"senderPhone,omitempty"`+ Contact *MessageContact `json:"contact,omitempty"`+ BackgroundColor string `json:"backgroundColor,omitempty"`+ Font int `json:"font,omitempty"`Media *ChatHistoryMedia `json:"media,omitempty"`QuotedMessage *QuotedMessage `json:"quotedMessage,omitempty"`Location *MessageLocation `json:"location,omitempty"`}+// MessageCall is the call block on a live history message, present on call messages only.+type MessageCall struct {+ Video bool `json:"video"`+ Missed bool `json:"missed"`+}++// MessageContact is the sender contact block on a live history message. History carries PushName+// only; the richer fields arrive on message.received when WEBHOOK_CONTACT_DETAILS is enabled.+type MessageContact struct {+ ID string `json:"id,omitempty"`+ Number string `json:"number,omitempty"`+ Name string `json:"name,omitempty"`+ PushName string `json:"pushName,omitempty"`+ ShortName string `json:"shortName,omitempty"`+ Type string `json:"type,omitempty"`+ IsMyContact bool `json:"isMyContact,omitempty"`+ IsWAContact bool `json:"isWAContact,omitempty"`+ IsBusiness bool `json:"isBusiness,omitempty"`+ IsEnterprise bool `json:"isEnterprise,omitempty"`+ VerifiedName string `json:"verifiedName,omitempty"`+ VerifiedLevel int `json:"verifiedLevel,omitempty"`+ IsBlocked bool `json:"isBlocked,omitempty"`+ Labels []string `json:"labels,omitempty"`+}+// ReactionSender is one sender within a ReactionRecord.type ReactionSender struct {SenderID string `json:"senderId"`diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/ChatHistoryMessage.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/ChatHistoryMessage.javaindex 8d63ee63a..4820f6763 100644--- a/sdk/java/src/main/java/com/rmyndharis/openwa/model/ChatHistoryMessage.java+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/ChatHistoryMessage.java@@ -20,11 +20,18 @@ public record ChatHistoryMessage(boolean isGroup,Boolean isStatusBroadcast,String kind,+ /** Disappearing-messages timer on the chat, in seconds; {@code null} when the chat has none. */+ Integer ephemeralDuration,/** For group messages, the participant who sent it ({@code from} is the group JID). */String author,List<String> mentionedIds,+ Call call,Boolean isLidSender,String senderPhone,+ Contact contact,+ /** Status/story styling. Declared by the engine payload; this route never sets either. */+ String backgroundColor,+ Integer font,Media media,QuotedMessage quotedMessage,Location location) {@@ -35,4 +42,27 @@ public record ChatHistoryMessage(public record QuotedMessage(String id, String body) {}public record Location(double latitude, double longitude, String description, String address, String url) {}++ /** Present on {@code call} messages only. */+ public record Call(Boolean video, Boolean missed) {}++ /**+ * Sender contact info. History carries {@code pushName} only; the richer fields arrive on+ * {@code message.received} when {@code WEBHOOK_CONTACT_DETAILS} is enabled.+ */+ public record Contact(+ String id,+ String number,+ String name,+ String pushName,+ String shortName,+ String type,+ Boolean isMyContact,+ Boolean isWAContact,+ Boolean isBusiness,+ Boolean isEnterprise,+ String verifiedName,+ Integer verifiedLevel,+ Boolean isBlocked,+ List<String> labels) {}}diff --git a/sdk/javascript/src/types.ts b/sdk/javascript/src/types.tsindex 254318c90..0a4aab6f7 100644--- a/sdk/javascript/src/types.ts+++ b/sdk/javascript/src/types.ts@@ -465,11 +465,38 @@ export interface ChatHistoryMessage {isGroup: boolean;isStatusBroadcast?: boolean;kind?: ChatKind;+ /** Disappearing-messages timer on the chat, in seconds. Absent when the chat has none set. */+ ephemeralDuration?: number;/** For group messages, the participant who sent it (`from` is the group JID). */author?: Jid;mentionedIds?: Jid[];+ /** Present on `call` messages only. */+ call?: { video: boolean; missed: boolean };isLidSender?: boolean;senderPhone?: string | null;+ /**+ * Sender contact info, best-effort from the engine's cache. History carries `pushName` only;+ * the richer fields arrive on `message.received` when `WEBHOOK_CONTACT_DETAILS=true`.+ */+ contact?: {+ id?: Jid;+ number?: string;+ name?: string;+ pushName?: string;+ shortName?: string;+ type?: string;+ isMyContact?: boolean;+ isWAContact?: boolean;+ isBusiness?: boolean;+ isEnterprise?: boolean;+ verifiedName?: string;+ verifiedLevel?: number;+ isBlocked?: boolean;+ labels?: string[];+ };+ /** Status/story styling. Declared by the engine payload; this route never sets either. */+ backgroundColor?: string;+ font?: number;media?: {mimetype: string;filename?: string;diff --git a/sdk/javascript/test/wire-contract.test-d.ts b/sdk/javascript/test/wire-contract.test-d.tsindex c87f238cb..80ba62c9e 100644--- a/sdk/javascript/test/wire-contract.test-d.ts+++ b/sdk/javascript/test/wire-contract.test-d.ts@@ -16,7 +16,14 @@* @packageDocumentation*/-import type { CatalogInfo, ChannelMessageRecord, ChannelRecord, LabelRecord, StatusRecord } from '../src/types.js';+import type {+ CatalogInfo,+ ChannelMessageRecord,+ ChannelRecord,+ ChatHistoryMessage,+ LabelRecord,+ StatusRecord,+} from '../src/types.js';/** `Label` — `hexColor` is the only colour field the wire shape carries. */interface WireLabel {@@ -64,6 +71,67 @@ interface WireChannelMessage {mediaUrl?: string;}+/**+ * `IncomingMessage` — `messages.history()` hands back the engine array verbatim, so the wire shape is+ * that interface serialized. `backgroundColor`/`font` are set by the Baileys extended-text mapper but+ * are not reachable through this route (Baileys answers `getChatHistory` with `unsupported`); they are+ * declared for the same forward-compatibility reason as on `WireStatus`.+ */+interface WireChatHistoryMessage {+ id: string;+ from: string;+ to: string;+ chatId: string;+ body: string;+ type:+ | 'text'+ | 'image'+ | 'video'+ | 'audio'+ | 'voice'+ | 'document'+ | 'sticker'+ | 'location'+ | 'contact'+ | 'poll'+ | 'call'+ | 'revoked'+ | 'masked'+ | 'unknown';+ timestamp: number;+ fromMe: boolean;+ isGroup: boolean;+ kind: 'individual' | 'group' | 'channel' | 'status' | 'broadcast' | 'unknown';+ isStatusBroadcast?: boolean;+ ephemeralDuration?: number;+ author?: string;+ mentionedIds?: string[];+ call?: { video: boolean; missed: boolean };+ isLidSender?: boolean;+ senderPhone?: string | null;+ contact?: {+ id?: string;+ number?: string;+ name?: string;+ pushName?: string;+ shortName?: string;+ type?: string;+ isMyContact?: boolean;+ isWAContact?: boolean;+ isBusiness?: boolean;+ isEnterprise?: boolean;+ verifiedName?: string;+ verifiedLevel?: number;+ isBlocked?: boolean;+ labels?: string[];+ };+ backgroundColor?: string;+ font?: number;+ media?: { mimetype: string; filename?: string; data?: string; omitted?: boolean; sizeBytes?: number };+ quotedMessage?: { id: string; body: string };+ location?: { latitude: number; longitude: number; description?: string; address?: string; url?: string };+}+/** `Catalog` — the control: this pair already agreed before #754 and must stay agreeing. */interface WireCatalog {id: string;@@ -92,5 +160,6 @@ const status: Mirrors<WireStatus, StatusRecord> = true;const channel: Mirrors<WireChannel, ChannelRecord> = true;const channelMessage: Mirrors<WireChannelMessage, ChannelMessageRecord> = true;const catalog: Mirrors<WireCatalog, CatalogInfo> = true;+const chatHistoryMessage: Mirrors<WireChatHistoryMessage, ChatHistoryMessage> = true;-export const contract = [label, status, channel, channelMessage, catalog];+export const contract = [label, status, channel, channelMessage, catalog, chatHistoryMessage];diff --git a/sdk/python/openwa/types.py b/sdk/python/openwa/types.pyindex 9b4023101..190440531 100644--- a/sdk/python/openwa/types.py+++ b/sdk/python/openwa/types.py@@ -446,6 +446,33 @@ class MessageLocation(TypedDict, total=False):url: str+class MessageCall(TypedDict, total=False):+ """Call block on a live history message, present on ``call`` messages only."""++ video: bool+ missed: bool+++class MessageContact(TypedDict, total=False):+ """Sender contact block. History carries ``pushName`` only; the richer fields arrive on+ ``message.received`` when ``WEBHOOK_CONTACT_DETAILS`` is enabled."""++ id: Jid+ number: str+ name: str+ pushName: str+ shortName: str+ type: str+ isMyContact: bool+ isWAContact: bool+ isBusiness: bool+ isEnterprise: bool+ verifiedName: str+ verifiedLevel: int+ isBlocked: bool+ labels: list++# A message read live from WhatsApp by ``messages.history()`` — the engine# payload, richer and differently shaped than the persisted MessageRecord.ChatHistoryMessage = TypedDict(@@ -462,10 +489,15 @@ ChatHistoryMessage = TypedDict("isGroup": bool,"isStatusBroadcast": bool,"kind": str,+ "ephemeralDuration": int,"author": Jid,"mentionedIds": list,+ "call": MessageCall,"isLidSender": bool,"senderPhone": Optional[str],+ "contact": MessageContact,+ "backgroundColor": str,+ "font": int,"media": ChatHistoryMedia,"quotedMessage": QuotedMessage,"location": MessageLocation,