Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(label): describe the label chats route with the full chat summary

Yudhi Armyndharis56bf256a7a1e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2a4cfd19b..5e6b07454 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,7 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
existed; the chat list never reported the resulting state back, so a consumer had no way to
filter archived chats out of its own view, order pinned chats first, or honour a mute — and
whatsapp-web.js's `chat_archived` event is deliberately not wired, so there was no event
- fallback either.
+ fallback either. `GET /sessions/{sessionId}/labels/{labelId}/chats` returns the same chat
+ summary, so it reports the three fields as well.
### Changed
diff --git a/openapi.json b/openapi.json
index 86aa66939..891fa9dfa 100644
--- a/openapi.json
+++ b/openapi.json
@@ -6479,7 +6479,7 @@
"schema": {
"type": "array",
"items": {
- "$ref": "#/components/schemas/LabelChatDto"
+ "$ref": "#/components/schemas/ChatSummaryDto"
}
}
}
@@ -14971,54 +14971,6 @@
"hexColor"
]
},
- "LabelChatDto": {
- "type": "object",
- "properties": {
- "id": {
- "type": "string",
- "description": "Chat id in the engine's native format.",
- "example": "[email protected]"
- },
- "name": {
- "type": "string",
- "description": "Chat title — contact name or group subject.",
- "example": "Ada Lovelace"
- },
- "isGroup": {
- "type": "boolean",
- "description": "Retained for back-compat; `kind` is the full discriminator.",
- "example": false
- },
- "kind": {
- "type": "string",
- "description": "User-facing chat kind.",
- "example": "individual"
- },
- "unreadCount": {
- "type": "number",
- "description": "Unread messages in this chat.",
- "example": 0
- },
- "timestamp": {
- "type": "number",
- "description": "Unix SECONDS of the most recent activity.",
- "example": 1786000000
- },
- "lastMessage": {
- "type": "string",
- "description": "Preview of the last message, when there is one.",
- "example": "See you then"
- }
- },
- "required": [
- "id",
- "name",
- "isGroup",
- "kind",
- "unreadCount",
- "timestamp"
- ]
- },
"UpsertLabelDto": {
"type": "object",
"properties": {
diff --git a/src/modules/label/dto/label-response.dto.ts b/src/modules/label/dto/label-response.dto.ts
index f889c0058..68461cf0e 100644
--- a/src/modules/label/dto/label-response.dto.ts
+++ b/src/modules/label/dto/label-response.dto.ts
@@ -1,4 +1,4 @@
-import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
+import { ApiProperty } from '@nestjs/swagger';
/**
* Response shapes for the label routes. These describe what the handlers already return — the
@@ -23,30 +23,6 @@ export class LabelDto {
hexColor!: string;
}
-/** A chat carrying a label. Same summary projection the chats list uses. */
-export class LabelChatDto {
- @ApiProperty({ description: "Chat id in the engine's native format.", example: '[email protected]' })
- id!: string;
-
- @ApiProperty({ description: 'Chat title — contact name or group subject.', example: 'Ada Lovelace' })
- name!: string;
-
- @ApiProperty({ description: 'Retained for back-compat; `kind` is the full discriminator.', example: false })
- isGroup!: boolean;
-
- @ApiProperty({ description: 'User-facing chat kind.', example: 'individual' })
- kind!: string;
-
- @ApiProperty({ description: 'Unread messages in this chat.', example: 0 })
- unreadCount!: number;
-
- @ApiProperty({ description: 'Unix SECONDS of the most recent activity.', example: 1786000000 })
- timestamp!: number;
-
- @ApiPropertyOptional({ description: 'Preview of the last message, when there is one.', example: 'See you then' })
- lastMessage?: string;
-}
-
export class LabelAckResponseDto {
@ApiProperty({ description: 'Always true — a failure is reported as a non-2xx status, not as false.', example: true })
success!: boolean;
diff --git a/src/modules/label/label.controller.ts b/src/modules/label/label.controller.ts
index d401d9ef3..4dfef13e1 100644
--- a/src/modules/label/label.controller.ts
+++ b/src/modules/label/label.controller.ts
@@ -1,6 +1,7 @@
import { Controller, Get, Post, Put, Delete, Param, Body, HttpCode, HttpStatus } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBody } from '@nestjs/swagger';
-import { LabelAckResponseDto, LabelChatDto, LabelDto } from './dto/label-response.dto';
+import { LabelAckResponseDto, LabelDto } from './dto/label-response.dto';
+import { ChatSummaryDto } from '../session/dto/chat-summary.dto';
import { LabelService } from './label.service';
import { AddLabelDto } from './dto/add-label.dto';
import { UpsertLabelDto } from './dto/upsert-label.dto';
@@ -48,7 +49,7 @@ export class LabelController {
})
@ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiParam({ name: 'labelId', description: 'Label ID' })
- @ApiResponse({ status: 200, description: 'Chats carrying the label', type: [LabelChatDto] })
+ @ApiResponse({ status: 200, description: 'Chats carrying the label', type: [ChatSummaryDto] })
@ApiResponse({ status: 400, description: 'Session not started' })
@ApiResponse({ status: 501, description: 'The active engine cannot list chats by label (Baileys)' })
@ApiResponse({