Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
feat(engine): surface archived state on ChatSummary
Surya1ef4a97ab05b
diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.tsindex a0fded4cc..bfcf12446 100644--- a/dashboard/src/services/api.ts+++ b/dashboard/src/services/api.ts@@ -214,6 +214,7 @@ export interface Chat {unreadCount: number;timestamp: number;lastMessage?: string;+ archived: boolean;}// Engine-neutral message types (mirrors the backend's IWhatsAppEngine MessageType). The backenddiff --git a/docs/06-api-specification.md b/docs/06-api-specification.mdindex 53c67c771..1f2bcf4e7 100644--- a/docs/06-api-specification.md+++ b/docs/06-api-specification.md@@ -417,7 +417,8 @@ Get active chats for a session, most-recent first (paginated)."kind": "individual","unreadCount": 2,"timestamp": 1719306115,- "lastMessage": "See you tomorrow"+ "lastMessage": "See you tomorrow",+ "archived": false}]```diff --git a/openapi.json b/openapi.jsonindex 0c6ac4ff7..945cecbf4 100644--- a/openapi.json+++ b/openapi.json@@ -10246,6 +10246,11 @@"lastMessage": {"type": "string","example": "hi"+ },+ "archived": {+ "type": "boolean",+ "description": "Archived state, as set via POST /sessions/{sessionId}/chats/archive.",+ "example": false}},"required": [@@ -10254,7 +10259,8 @@"isGroup","kind","unreadCount",- "timestamp"+ "timestamp",+ "archived"]},"MarkChatReadDto": {diff --git a/sdk/go/types_chat.go b/sdk/go/types_chat.goindex 9f5e7d3a1..fcda385c0 100644--- a/sdk/go/types_chat.go+++ b/sdk/go/types_chat.go@@ -11,6 +11,7 @@ type ChatSummary struct {LastMessage string `json:"lastMessage,omitempty"`Timestamp int64 `json:"timestamp"`Kind ChatKind `json:"kind"`+ Archived bool `json:"archived"`}// SetOwnPresenceRequest is the body for SessionsService.SetOnlinePresence. Available reportsdiff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/ChatSummary.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/ChatSummary.javaindex 9b79436ba..f501a31d0 100644--- a/sdk/java/src/main/java/com/rmyndharis/openwa/model/ChatSummary.java+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/ChatSummary.java@@ -14,4 +14,5 @@ public record ChatSummary(/** Preview text of the last message (the server returns a plain string, not an object). */String lastMessage,Long timestamp,- ChatKind kind) {}+ ChatKind kind,+ Boolean archived) {}diff --git a/sdk/javascript/src/types.ts b/sdk/javascript/src/types.tsindex 68c66c182..861a0325a 100644--- a/sdk/javascript/src/types.ts+++ b/sdk/javascript/src/types.ts@@ -942,6 +942,8 @@ export interface ChatSummary {/** Unix seconds of the last activity. */timestamp: number;kind: ChatKind;+ /** Archived state, as set via {@link ChatsResource.archive}. */+ archived: boolean;}/** Body for {@link SessionsResource.setOnlinePresence}. */diff --git a/sdk/python/openwa/types.py b/sdk/python/openwa/types.pyindex b120b3f11..d6e103d46 100644--- a/sdk/python/openwa/types.py+++ b/sdk/python/openwa/types.py@@ -888,6 +888,7 @@ class ChatSummary(TypedDict):lastMessage: NotRequired[str]timestamp: str | intkind: ChatKind+ archived: boolclass MarkChatRequest(TypedDict):diff --git a/src/engine/adapters/baileys-session-store.spec.ts b/src/engine/adapters/baileys-session-store.spec.tsindex fc56ae60b..a4ccb88dd 100644--- a/src/engine/adapters/baileys-session-store.spec.ts+++ b/src/engine/adapters/baileys-session-store.spec.ts@@ -64,6 +64,7 @@ describe('BaileysSessionStore', () => {unreadCount: 2,timestamp: 200,lastMessage: 'newest',+ archived: false,},]);expect(store.lastMessage('[email protected]')).toEqual({diff --git a/src/engine/adapters/baileys-session-store.ts b/src/engine/adapters/baileys-session-store.tsindex 92145f477..6106a1aa2 100644--- a/src/engine/adapters/baileys-session-store.ts+++ b/src/engine/adapters/baileys-session-store.ts@@ -388,6 +388,7 @@ export class BaileysSessionStore {unreadCount: c.unreadCount ?? 0,timestamp: last?.timestamp ?? this.toUnixSeconds(c.conversationTimestamp),lastMessage: last?.text,+ archived: c.archived ?? false,};}diff --git a/src/engine/adapters/baileys.adapter.spec.ts b/src/engine/adapters/baileys.adapter.spec.tsindex 1ba6f094b..5411f145a 100644--- a/src/engine/adapters/baileys.adapter.spec.ts+++ b/src/engine/adapters/baileys.adapter.spec.ts@@ -4262,6 +4262,7 @@ describe('BaileysAdapter contact + chat reads', () => {unreadCount: 1,timestamp: 1700000010,lastMessage: 'hi',+ archived: false,});});diff --git a/src/engine/adapters/wwebjs-chats.ts b/src/engine/adapters/wwebjs-chats.tsindex 81338d0f6..616935f7f 100644--- a/src/engine/adapters/wwebjs-chats.ts+++ b/src/engine/adapters/wwebjs-chats.ts@@ -60,6 +60,7 @@ export class WwebjsChats {timestamp: chat.timestamp || 0,// A location message's body is the base64 map thumbnail; don't surface it as the chat preview.lastMessage: chat.lastMessage?.type === MessageTypes.LOCATION ? '📍' : chat.lastMessage?.body || undefined,+ archived: Boolean(chat.archived),});}diff --git a/src/engine/adapters/wwebjs-labels.ts b/src/engine/adapters/wwebjs-labels.tsindex 5a59bf260..5bb946bec 100644--- a/src/engine/adapters/wwebjs-labels.ts+++ b/src/engine/adapters/wwebjs-labels.ts@@ -74,6 +74,7 @@ export class WwebjsLabels {kind: chatKind(id),unreadCount: chat.unreadCount || 0,timestamp: chat.timestamp || 0,+ archived: Boolean(chat.archived),});}return summaries;diff --git a/src/engine/interfaces/whatsapp-engine.interface.ts b/src/engine/interfaces/whatsapp-engine.interface.tsindex 648b7211d..c04221044 100644--- a/src/engine/interfaces/whatsapp-engine.interface.ts+++ b/src/engine/interfaces/whatsapp-engine.interface.ts@@ -491,6 +491,8 @@ export interface ChatSummary {unreadCount: number;timestamp: number;lastMessage?: string;+ /** Archived state, as set via `POST /sessions/{sessionId}/chats/archive`. */+ archived: boolean;}/**diff --git a/src/engine/types/whatsapp-web-js.types.ts b/src/engine/types/whatsapp-web-js.types.tsindex f9811e07b..4596ee998 100644--- a/src/engine/types/whatsapp-web-js.types.ts+++ b/src/engine/types/whatsapp-web-js.types.ts@@ -134,7 +134,14 @@ export interface BusinessClient extends Omit<labelId: string,): Promise<Array<- | { id?: { _serialized?: string }; name?: string; isGroup?: boolean; unreadCount?: number; timestamp?: number }+ | {+ id?: { _serialized?: string };+ name?: string;+ isGroup?: boolean;+ unreadCount?: number;+ timestamp?: number;+ archived?: boolean;+ }| undefined>>;diff --git a/src/modules/session/dto/chat-summary.dto.ts b/src/modules/session/dto/chat-summary.dto.tsindex 506c73277..0abcadaf7 100644--- a/src/modules/session/dto/chat-summary.dto.ts+++ b/src/modules/session/dto/chat-summary.dto.ts@@ -25,4 +25,7 @@ export class ChatSummaryDto {@ApiPropertyOptional({ example: 'hi' })lastMessage?: string;++ @ApiProperty({ description: 'Archived state, as set via POST /sessions/{sessionId}/chats/archive.', example: false })+ archived!: boolean;}