Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(sdk): split the mark-read body in the other four clients
m7fz7f5820a6c9351
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex dc865c210..bbea7df27 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Added-- `POST /sessions/{sessionId}/chats/read` accepts an optional `messageIds` array (up to 100) naming exactly which messages to acknowledge. Baileys acknowledges individual messages, so without it only the newest message still held in memory got a receipt: a burst left its earlier messages unread, and a session restarted since the message arrived had nothing to acknowledge and answered `false` under a `200`. Each id is resolved through the message store, so a group receipt carries the `participant` that attributes it. Omitting the field keeps the previous behaviour, an empty array is refused with a `400` rather than silently acknowledging the newest message, and the whatsapp-web.js engine ignores the field because its own receipt is chat-level. The `SessionMarkChatRead` agent tool takes the same list.+- `POST /sessions/{sessionId}/chats/read` accepts an optional `messageIds` array (up to 100) naming exactly which messages to acknowledge. Baileys acknowledges individual messages, so without it only the newest message still held in memory got a receipt: a burst left its earlier messages unread, and a session restarted since the message arrived had nothing to acknowledge and answered `false` under a `200`. Each id is resolved through the message store, so a group receipt carries the `participant` that attributes it. Omitting the field keeps the previous behaviour, an empty array is refused with a `400` rather than silently acknowledging the newest message, and the whatsapp-web.js engine ignores the field because its own receipt is chat-level. The `SessionMarkChatRead` agent tool takes the same list, and all five clients expose the field through a dedicated read-request type.### Changeddiff --git a/scripts/check-contract-shapes.mjs b/scripts/check-contract-shapes.mjsindex 534ec0e4f..a52cda7bb 100644--- a/scripts/check-contract-shapes.mjs+++ b/scripts/check-contract-shapes.mjs@@ -167,9 +167,9 @@ const MAPPINGS = {const MINIMUM_MAPPED = {'sdk/javascript/src/types.ts': 79,'dashboard/src/services/api.ts': 20,- 'sdk/python/openwa/types.py': 73,- 'sdk/go': 74,- 'sdk/java': 78,+ 'sdk/python/openwa/types.py': 74,+ 'sdk/go': 75,+ 'sdk/java': 79,};/** Known drift, deliberately not gated yet — each line is a to-adjudicate follow-up. */@@ -231,7 +231,8 @@ const PYTHON_MAPPING = {GroupParticipant: 'GroupParticipantDto',GroupSummary: 'GroupSummaryDto',JoinGroupRequest: 'JoinGroupDto',- MarkChatRequest: 'MarkChatReadDto',+ MarkChatReadRequest: 'MarkChatReadDto',+ MarkChatRequest: 'MarkChatUnreadDto',MessageListResponse: 'MessageListResponseDto',MessageRecord: 'MessageListItemDto',MessageResponse: 'MessageResponseDto',@@ -308,7 +309,8 @@ const GO_MAPPING = {GroupParticipant: 'GroupParticipantDto',GroupSummary: 'GroupSummaryDto',JoinGroupRequest: 'JoinGroupDto',- MarkChatRequest: 'MarkChatReadDto',+ MarkChatReadRequest: 'MarkChatReadDto',+ MarkChatRequest: 'MarkChatUnreadDto',MessageListResponse: 'MessageListResponseDto',MessageRecord: 'MessageListItemDto',MessageResponse: 'MessageResponseDto',@@ -389,7 +391,8 @@ const JAVA_MAPPING = {GroupSubjectRequest: 'GroupSubjectDto',GroupSummary: 'GroupSummaryDto',JoinGroupRequest: 'JoinGroupDto',- MarkChatRequest: 'MarkChatReadDto',+ MarkChatReadRequest: 'MarkChatReadDto',+ MarkChatRequest: 'MarkChatUnreadDto',MessageListResponse: 'MessageListResponseDto',MessageRecord: 'MessageListItemDto',MessageResponse: 'MessageResponseDto',diff --git a/sdk/go/chats.go b/sdk/go/chats.goindex 146dbe8f1..52f693a1c 100644--- a/sdk/go/chats.go+++ b/sdk/go/chats.go@@ -41,7 +41,7 @@ func (s *ChatsService) GetPresence(ctx context.Context, sessionID, chatID string}// MarkRead marks a chat as read.-func (s *ChatsService) MarkRead(ctx context.Context, sessionID string, body MarkChatRequest) (*SuccessResult, error) {+func (s *ChatsService) MarkRead(ctx context.Context, sessionID string, body MarkChatReadRequest) (*SuccessResult, error) {return s.post(ctx, sessionID, "/read", body)}diff --git a/sdk/go/routing_test.go b/sdk/go/routing_test.goindex c360a266a..089edaa3a 100644--- a/sdk/go/routing_test.go+++ b/sdk/go/routing_test.go@@ -94,7 +94,7 @@ func TestRouting(t *testing.T) {{"Webhooks.Test", func(c *Client) { c.Webhooks.Test(ctx, "s1", "w1") }, "POST", "/api/sessions/s1/webhooks/w1/test"},{"Chats.List", func(c *Client) { c.Chats.List(ctx, "s1", nil) }, "GET", "/api/sessions/s1/chats"},- {"Chats.MarkRead", func(c *Client) { c.Chats.MarkRead(ctx, "s1", MarkChatRequest{}) }, "POST", "/api/sessions/s1/chats/read"},+ {"Chats.MarkRead", func(c *Client) { c.Chats.MarkRead(ctx, "s1", MarkChatReadRequest{}) }, "POST", "/api/sessions/s1/chats/read"},{"Chats.SubscribePresence", func(c *Client) { c.Chats.SubscribePresence(ctx, "s1", MarkChatRequest{}) }, "POST", "/api/sessions/s1/presence/subscribe"},{"Channels.Create", func(c *Client) { c.Channels.Create(ctx, "s1", CreateChannelRequest{}) }, "POST", "/api/sessions/s1/channels"},{"Channels.Delete", func(c *Client) { c.Channels.Delete(ctx, "s1", "ch1") }, "POST", "/api/sessions/s1/channels/ch1/delete"},diff --git a/sdk/go/types_chat.go b/sdk/go/types_chat.goindex 431452ecb..f6f24ac50 100644--- a/sdk/go/types_chat.go+++ b/sdk/go/types_chat.go@@ -19,11 +19,20 @@ type SetOwnPresenceRequest struct {Available bool `json:"available"`}-// MarkChatRequest marks a chat read/unread.+// MarkChatRequest marks a chat unread, or subscribes to its presence.type MarkChatRequest struct {ChatID string `json:"chatId"`}+// MarkChatReadRequest marks a chat read, optionally naming the messages to acknowledge.+type MarkChatReadRequest struct {+ ChatID string `json:"chatId"`+ // MessageIDs are the messages to acknowledge (at most 100; an empty list is refused). Baileys+ // acknowledges individual messages, so without this only the newest message the engine still+ // holds in memory gets a receipt. Ignored by whatsapp-web.js, whose own sendSeen is chat-level.+ MessageIDs []string `json:"messageIds,omitempty"`+}+// ChatState is the typing indicator a chat shows.type ChatState stringdiff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/MarkChatReadRequest.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/MarkChatReadRequest.javanew file mode 100644index 000000000..d46dc497f--- /dev/null+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/MarkChatReadRequest.java@@ -0,0 +1,35 @@+package com.rmyndharis.openwa.model;++import java.util.List;++/** Request body for marking a chat read. */+public record MarkChatReadRequest(String chatId, List<String> messageIds) {+ public static Builder builder() {+ return new Builder();+ }++ public static final class Builder {+ private String chatId;+ private List<String> messageIds;++ /** WhatsApp chat id (JID), e.g. {@code [email protected]}. */+ public Builder chatId(String v) {+ this.chatId = v;+ return this;+ }++ /**+ * Messages to acknowledge (at most 100; an empty list is refused). Baileys acknowledges+ * individual messages, so without this only the newest message the engine still holds in+ * memory gets a receipt. Ignored by whatsapp-web.js, whose own sendSeen is chat-level.+ */+ public Builder messageIds(List<String> v) {+ this.messageIds = v;+ return this;+ }++ public MarkChatReadRequest build() {+ return new MarkChatReadRequest(chatId, messageIds);+ }+ }+}diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/MarkChatRequest.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/MarkChatRequest.javaindex 2dd067d92..c11efb5de 100644--- a/sdk/java/src/main/java/com/rmyndharis/openwa/model/MarkChatRequest.java+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/MarkChatRequest.java@@ -1,6 +1,6 @@package com.rmyndharis.openwa.model;-/** Request body for marking a chat read/unread. */+/** Request body for marking a chat unread, or subscribing to its presence. */public record MarkChatRequest(String chatId) {public static Builder builder() {return new Builder();diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/resources/ChatsResource.java b/sdk/java/src/main/java/com/rmyndharis/openwa/resources/ChatsResource.javaindex ea910e54a..6fd66a25e 100644--- a/sdk/java/src/main/java/com/rmyndharis/openwa/resources/ChatsResource.java+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/resources/ChatsResource.java@@ -9,6 +9,7 @@ import com.rmyndharis.openwa.model.ChatPresence;import com.rmyndharis.openwa.model.ChatSummary;import com.rmyndharis.openwa.model.DeleteChatRequest;import com.rmyndharis.openwa.model.ListChatsQuery;+import com.rmyndharis.openwa.model.MarkChatReadRequest;import com.rmyndharis.openwa.model.MarkChatRequest;import com.rmyndharis.openwa.model.MuteChatRequest;import com.rmyndharis.openwa.model.PinChatRequest;@@ -72,7 +73,7 @@ public final class ChatsResource {}/** Mark a chat as read/seen. */- public SuccessResult markRead(String sessionId, MarkChatRequest body) {+ public SuccessResult markRead(String sessionId, MarkChatReadRequest body) {return client.request(HttpMethod.POST, "/api/sessions/" + encodeSegment(sessionId) + "/chats/read", null, body, SuccessResult.class);}diff --git a/sdk/java/src/test/java/com/rmyndharis/openwa/resources/ChatsResourceTest.java b/sdk/java/src/test/java/com/rmyndharis/openwa/resources/ChatsResourceTest.javaindex 979ec295e..03f6091a8 100644--- a/sdk/java/src/test/java/com/rmyndharis/openwa/resources/ChatsResourceTest.java+++ b/sdk/java/src/test/java/com/rmyndharis/openwa/resources/ChatsResourceTest.java@@ -12,6 +12,7 @@ import com.rmyndharis.openwa.model.DeleteChatRequest;import com.rmyndharis.openwa.model.MuteChatRequest;import com.rmyndharis.openwa.model.PinChatRequest;import com.rmyndharis.openwa.model.ListChatsQuery;+import com.rmyndharis.openwa.model.MarkChatReadRequest;import com.rmyndharis.openwa.model.MarkChatRequest;import com.rmyndharis.openwa.model.SendChatStateRequest;import com.rmyndharis.openwa.support.MockTransport;@@ -48,7 +49,7 @@ class ChatsResourceTest {@Testvoid markReadSendsBody() {tx.respond(200, "{\"success\":true}");- client.chats.markRead("s", MarkChatRequest.builder().chatId("[email protected]").build());+ client.chats.markRead("s", MarkChatReadRequest.builder().chatId("[email protected]").build());assertEquals("http://h/api/sessions/s/chats/read", tx.lastRequest().url());assertEquals(HttpMethod.POST, tx.lastRequest().method());assertTrue(tx.lastRequest().body().contains("[email protected]"));diff --git a/sdk/python/openwa/resources/chats.py b/sdk/python/openwa/resources/chats.pyindex 3ec599ccc..13866069a 100644--- a/sdk/python/openwa/resources/chats.py+++ b/sdk/python/openwa/resources/chats.py@@ -16,6 +16,7 @@ from ..types import (MuteChatRequest,ChatSummary,DeleteChatRequest,+ MarkChatReadRequest,MarkChatRequest,SendChatStateRequest,SuccessResult,@@ -59,7 +60,7 @@ class ChatsResource:"GET", f"/api/sessions/{quote_segment(session_id)}/presence/{quote_segment(chat_id)}")- def mark_read(self, session_id: str, body: MarkChatRequest) -> SuccessResult:+ def mark_read(self, session_id: str, body: MarkChatReadRequest) -> SuccessResult:return self._http.request("POST", f"/api/sessions/{quote_segment(session_id)}/chats/read", body=body)def mark_unread(self, session_id: str, body: MarkChatRequest) -> SuccessResult:diff --git a/sdk/python/openwa/types.py b/sdk/python/openwa/types.pyindex 6216d872d..182c03f97 100644--- a/sdk/python/openwa/types.py+++ b/sdk/python/openwa/types.py@@ -882,9 +882,19 @@ class ChatSummary(TypedDict):class MarkChatRequest(TypedDict):+ # Body for mark_unread and subscribe_presence, both of which take the chat id alone.chatId: Jid+class MarkChatReadRequest(TypedDict):+ # Body for mark_read.+ chatId: Jid+ # Messages to acknowledge (at most 100; an empty list is refused). Baileys acknowledges+ # individual messages, so without this only the newest message the engine still holds in+ # memory gets a receipt. Ignored by whatsapp-web.js, whose own sendSeen is chat-level.+ messageIds: NotRequired[list[str]]++class SendChatStateRequest(TypedDict):chatId: Jidstate: ChatState