Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(message): refuse a chat id without a domain before the engine
Yudhi Armyndharis0fccb63f99ec
diff --git a/src/core/agent-tools/tools/message.tools.spec.ts b/src/core/agent-tools/tools/message.tools.spec.tsindex 2ae984ebf..51ea904e9 100644--- a/src/core/agent-tools/tools/message.tools.spec.ts+++ b/src/core/agent-tools/tools/message.tools.spec.ts@@ -328,6 +328,24 @@ describe('messageTools', () => {expect(sendText).not.toHaveBeenCalled();});+ it.each([+ ['MessageSendText', { text: 'hi' }],+ ['MessageSendLocation', { latitude: 1, longitude: 2 }],+ ['MessageReact', { messageId: 'm1', emoji: 'π' }],+ ])('%s refuses a chat id that is no JID before the service sees it', async (name, rest) => {+ // The tool calls the service directly, so no ValidationPipe holds the rule for it; an id the engine+ // cannot decode otherwise ends as a 500 and counts against the session's send breaker.+ const service = { sendText: jest.fn(), sendLocation: jest.fn(), reactToMessage: jest.fn() };+ const tools = makeTools(service as unknown as MessageService);++ await expect(run(tools.get(name)!, { sessionId: 's1', chatId: '6281270008896', ...rest })).rejects.toMatchObject({+ response: { message: [expect.stringContaining('localpart@host') as unknown as string] },+ });+ expect(service.sendText).not.toHaveBeenCalled();+ expect(service.sendLocation).not.toHaveBeenCalled();+ expect(service.reactToMessage).not.toHaveBeenCalled();+ });+it('forwards a caller-supplied link preview, and enforces the title WhatsApp requires', async () => {// REST declares customLinkPreview; the tool did not, so an agent's object was stripped before the// handler ran and the send went out with whatever preview the engine chose on its own.diff --git a/src/core/agent-tools/tools/message.tools.ts b/src/core/agent-tools/tools/message.tools.tsindex e0ebb40a9..163310bf6 100644--- a/src/core/agent-tools/tools/message.tools.ts+++ b/src/core/agent-tools/tools/message.tools.ts@@ -19,7 +19,7 @@ import {LOCATION_TEXT_MAX_LENGTH,REACTION_EMOJI_MAX_LENGTH,} from '../../../modules/message/dto/message-actions.dto';-import { chatIdSchema } from '../chat-id-schema';+import { chatIdSchema, chatJidSchema } from '../chat-id-schema';import { defineTool, type AnyToolDescriptor } from '../tool-descriptor';const sessionId = z.string().min(1).describe('Session UUID (the session id, not the name)');@@ -160,7 +160,7 @@ export function messageTools(message: MessageService): AnyToolDescriptor[] {sessionScoped: true,inputSchema: z.object({sessionId,- chatId: chatIdSchema.describe('Chat JID (e.g. [email protected] or [email protected])'),+ chatId: chatJidSchema.describe('Chat JID (e.g. [email protected] or [email protected])'),text: z.string().min(1).max(MESSAGE_TEXT_MAX_LENGTH).describe('Text message content'),linkPreview: z.boolean()@@ -193,7 +193,7 @@ export function messageTools(message: MessageService): AnyToolDescriptor[] {inputSchema: z.object({sessionId,- chatId: chatIdSchema.describe('Chat JID'),+ chatId: chatJidSchema.describe('Chat JID'),url: mediaUrl('Image'),base64: z.string().optional().describe('Base64-encoded image data'),mimetype: z.string().optional().describe('MIME type (required when using base64)'),@@ -225,7 +225,7 @@ export function messageTools(message: MessageService): AnyToolDescriptor[] {inputSchema: z.object({sessionId,- chatId: chatIdSchema.describe('Chat JID'),+ chatId: chatJidSchema.describe('Chat JID'),url: mediaUrl('Video'),base64: z.string().optional().describe('Base64-encoded video data'),mimetype: z.string().optional().describe('MIME type (required when using base64)'),@@ -257,7 +257,7 @@ export function messageTools(message: MessageService): AnyToolDescriptor[] {inputSchema: z.object({sessionId,- chatId: chatIdSchema.describe('Chat JID'),+ chatId: chatJidSchema.describe('Chat JID'),url: mediaUrl('Audio'),base64: z.string().optional().describe('Base64-encoded audio data'),mimetype: z.string().optional().describe('MIME type (required when using base64)'),@@ -291,7 +291,7 @@ export function messageTools(message: MessageService): AnyToolDescriptor[] {inputSchema: z.object({sessionId,- chatId: chatIdSchema.describe('Chat JID'),+ chatId: chatJidSchema.describe('Chat JID'),url: mediaUrl('Document'),base64: z.string().optional().describe('Base64-encoded document data'),mimetype: z.string().optional().describe('MIME type (required when using base64)'),@@ -322,7 +322,7 @@ export function messageTools(message: MessageService): AnyToolDescriptor[] {sessionScoped: true,inputSchema: z.object({sessionId,- chatId: chatIdSchema.describe('Chat JID'),+ chatId: chatJidSchema.describe('Chat JID'),latitude: z.number().min(-90).max(90).describe('Latitude coordinate'),longitude: z.number().min(-180).max(180).describe('Longitude coordinate'),description: z.string().max(LOCATION_TEXT_MAX_LENGTH).optional().describe('Location label/description'),@@ -348,7 +348,7 @@ export function messageTools(message: MessageService): AnyToolDescriptor[] {sessionScoped: true,inputSchema: z.object({sessionId,- chatId: chatIdSchema.describe('Chat JID'),+ chatId: chatJidSchema.describe('Chat JID'),contactName: z.string().min(1).max(CONTACT_NAME_MAX_LENGTH).describe('Display name of the contact to share'),contactNumber: z.string()@@ -375,7 +375,7 @@ export function messageTools(message: MessageService): AnyToolDescriptor[] {inputSchema: z.object({sessionId,- chatId: chatIdSchema.describe('Chat JID'),+ chatId: chatJidSchema.describe('Chat JID'),url: mediaUrl('Sticker'),base64: z.string().optional().describe('Base64-encoded sticker data'),mimetype: z.string().optional().describe('MIME type (required when using base64)'),@@ -407,7 +407,7 @@ export function messageTools(message: MessageService): AnyToolDescriptor[] {sessionScoped: true,inputSchema: z.object({sessionId,- chatId: chatIdSchema.describe('Chat JID'),+ chatId: chatJidSchema.describe('Chat JID'),templateId: z.string().optional().describe('Template UUID'),templateName: z.string().optional().describe('Template name slug'),vars: z@@ -435,7 +435,7 @@ export function messageTools(message: MessageService): AnyToolDescriptor[] {sessionScoped: true,inputSchema: z.object({sessionId,- chatId: chatIdSchema.describe('Chat JID'),+ chatId: chatJidSchema.describe('Chat JID'),quotedMessageId: z.string().min(1).describe('ID of the message to quote/reply to'),text: z.string().min(1).max(MESSAGE_TEXT_MAX_LENGTH).describe('Reply text content'),mentions: mentionsSchema,@@ -457,8 +457,8 @@ export function messageTools(message: MessageService): AnyToolDescriptor[] {sessionScoped: true,inputSchema: z.object({sessionId,- fromChatId: chatIdSchema.describe('Source chat JID'),- toChatId: chatIdSchema.describe('Destination chat JID'),+ fromChatId: chatJidSchema.describe('Source chat JID'),+ toChatId: chatJidSchema.describe('Destination chat JID'),messageId: z.string().min(1).describe('ID of the message to forward'),}),handler: input =>@@ -478,7 +478,7 @@ export function messageTools(message: MessageService): AnyToolDescriptor[] {sessionScoped: true,inputSchema: z.object({sessionId,- chatId: chatIdSchema.describe('Chat JID containing the message'),+ chatId: chatJidSchema.describe('Chat JID containing the message'),messageId: z.string().min(1).describe('ID of the message to react to'),emoji: z.string()diff --git a/src/modules/catalog/dto/send-product.dto.spec.ts b/src/modules/catalog/dto/send-product.dto.spec.tsindex f0a5426dd..16d2bcdae 100644--- a/src/modules/catalog/dto/send-product.dto.spec.ts+++ b/src/modules/catalog/dto/send-product.dto.spec.ts@@ -19,7 +19,7 @@ describe('SendProductDto', () => {});it('rejects an empty chatId or productId', async () => {- expect(await failures({ ...valid, chatId: '' })).toEqual({ chatId: ['isNotEmpty'] });+ expect(await failures({ ...valid, chatId: '' })).toEqual({ chatId: ['matches', 'isNotEmpty'] });expect(await failures({ ...valid, productId: '' })).toEqual({ productId: ['isNotEmpty'] });});diff --git a/src/modules/catalog/dto/send-product.dto.ts b/src/modules/catalog/dto/send-product.dto.tsindex a1e5db0a7..078316342 100644--- a/src/modules/catalog/dto/send-product.dto.ts+++ b/src/modules/catalog/dto/send-product.dto.ts@@ -1,8 +1,8 @@-import { IsString, IsOptional, IsInt, Min, IsNotEmpty, MaxLength } from 'class-validator';+import { IsString, IsOptional, IsInt, Min, IsNotEmpty, MaxLength, Matches } from 'class-validator';import { Type } from 'class-transformer';import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';import { MESSAGE_TEXT_MAX_LENGTH } from '../../message/dto/send-message.dto';-import { CHAT_ID_MAX_LENGTH } from '../../message/dto/send-message.dto';+import { CHAT_ID_MAX_LENGTH, CHAT_JID_MESSAGE, CHAT_JID_PATTERN } from '../../message/dto/send-message.dto';import { ToStrictString } from '../../../common/utils/strict-boolean';/** WhatsApp catalog product ids are numeric strings of about 16-20 digits; this leaves wide headroom. */@@ -18,6 +18,7 @@ export class SendProductDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty({ description: 'Catalog product id to send.', example: 'product-42', maxLength: PRODUCT_ID_MAX_LENGTH })diff --git a/src/modules/message/dto/bulk-message.dto.ts b/src/modules/message/dto/bulk-message.dto.tsindex 273c28506..a6dbaa1f4 100644--- a/src/modules/message/dto/bulk-message.dto.ts+++ b/src/modules/message/dto/bulk-message.dto.ts@@ -15,6 +15,7 @@ import {ArrayMaxSize,ValidatorConstraint,ValidatorConstraintInterface,+ Matches,} from 'class-validator';import { Type } from 'class-transformer';import { Validate } from 'class-validator';@@ -22,6 +23,8 @@ import { ToStrictArray, ToStrictBoolean, ToStrictString } from '../../../common/import {BATCH_ID_MAX_LENGTH,CHAT_ID_MAX_LENGTH,+ CHAT_JID_MESSAGE,+ CHAT_JID_PATTERN,MENTIONS_DESCRIPTION,MENTIONS_MAX,MENTION_WID_MAX_LENGTH,@@ -150,6 +153,7 @@ class BulkMessageItemDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty({ description: 'Message type', enum: ['text', 'image', 'video', 'audio', 'document'] })diff --git a/src/modules/message/dto/chat-jid.dto.spec.ts b/src/modules/message/dto/chat-jid.dto.spec.tsnew file mode 100644index 000000000..e57ad6c36--- /dev/null+++ b/src/modules/message/dto/chat-jid.dto.spec.ts@@ -0,0 +1,72 @@+import { readdirSync, readFileSync, statSync } from 'fs';+import { join } from 'path';+import { plainToInstance } from 'class-transformer';+import { validate } from 'class-validator';+import { SendMediaMessageDto, SendTextMessageDto } from './send-message.dto';+import { ForwardMessageDto, ReactMessageDto, SendLocationDto } from './message-actions.dto';+import { GLOBAL_VALIDATION_OPTIONS } from '../../../config/app-validation';++const validateDto = (cls: new () => object, obj: unknown) =>+ validate(plainToInstance(cls, obj, GLOBAL_VALIDATION_OPTIONS.transformOptions), GLOBAL_VALIDATION_OPTIONS);+const failedProperties = async (cls: new () => object, obj: unknown): Promise<string[]> =>+ (await validateDto(cls, obj)).map(e => e.property);++// An id the engine cannot decode (no domain, or whitespace) used to reach it: Baileys threw a TypeError out+// of `jidDecode`, the caller saw a 500, and the send breaker counted it against a healthy session.+describe('a chat id on a send or action body must be localpart@host', () => {+ const refused = ['x', '6281270008896', '628127 [email protected]', '@c.us', 'abc@', 628123456789];+ const accepted = ['[email protected]', '[email protected]', '[email protected]', '1234567890123@lid'];++ it.each(refused)('refuses %j on a text send', async chatId => {+ expect(await failedProperties(SendTextMessageDto, { chatId, text: 'hi' })).toEqual(['chatId']);+ });++ it.each(accepted)('accepts %j on a text send', async chatId => {+ expect(await failedProperties(SendTextMessageDto, { chatId, text: 'hi' })).toEqual([]);+ });++ it('holds on the media, location, reaction and forward bodies too', async () => {+ expect(await failedProperties(SendMediaMessageDto, { chatId: 'x', url: 'https://example.com/a.png' })).toEqual([+ 'chatId',+ ]);+ expect(await failedProperties(SendLocationDto, { chatId: 'x', latitude: 1, longitude: 2 })).toEqual(['chatId']);+ expect(await failedProperties(ReactMessageDto, { chatId: 'x', messageId: 'm', emoji: 'π' })).toEqual(['chatId']);+ const forward = { fromChatId: '[email protected]', toChatId: '[email protected]', messageId: 'm' };+ expect(await failedProperties(ForwardMessageDto, forward)).toEqual([]);+ expect(await failedProperties(ForwardMessageDto, { ...forward, fromChatId: 'x' })).toEqual(['fromChatId']);+ expect(await failedProperties(ForwardMessageDto, { ...forward, toChatId: 'x' })).toEqual(['toChatId']);+ });+});++// A request body that names a chat is checked with the shared pattern wherever it is declared, so a DTO+// added later cannot reintroduce the 500 by leaving the pattern out.+describe('every request DTO that names a chat holds the JID pattern', () => {+ const root = join(__dirname, '..', '..');+ const dtoFiles = (dir: string): string[] =>+ readdirSync(dir).flatMap(name => {+ const path = join(dir, name);+ if (statSync(path).isDirectory()) return dtoFiles(path);+ return name.endsWith('.dto.ts') ? [path] : [];+ });++ it('finds the declarations and none lacks the pattern', () => {+ const declaration = /^\s+(chatId|toChatId|fromChatId)!:\s*string;/;+ const missing: string[] = [];+ let seen = 0;+ for (const file of dtoFiles(root)) {+ const lines = readFileSync(file, 'utf8').split('\n');+ lines.forEach((line, index) => {+ if (!declaration.test(line)) return;+ const decorators = lines.slice(Math.max(0, index - 10), index).join('\n');+ if (!decorators.includes('@IsString()')) return; // a response field, nothing validates it+ seen += 1;+ // Four older DTOs spell the same regular expression out instead of importing the constant.+ if (!decorators.includes('CHAT_JID_PATTERN') && !decorators.includes('[^\\s@]+@[^\\s@]+')) {+ missing.push(`${file}:${index + 1}`);+ }+ });+ }+ expect(seen).toBeGreaterThanOrEqual(27);+ expect(missing).toEqual([]);+ });+});diff --git a/src/modules/message/dto/message-actions.dto.ts b/src/modules/message/dto/message-actions.dto.tsindex 2ca74a819..4a668a489 100644--- a/src/modules/message/dto/message-actions.dto.ts+++ b/src/modules/message/dto/message-actions.dto.ts@@ -12,10 +12,13 @@ import {MaxLength,IsIn,Validate,+ Matches,} from 'class-validator';import { ToStrictArray, ToStrictBoolean, ToStrictNumber, ToStrictString } from '../../../common/utils/strict-boolean';import {CHAT_ID_MAX_LENGTH,+ CHAT_JID_MESSAGE,+ CHAT_JID_PATTERN,MENTIONS_DESCRIPTION,MENTIONS_MAX,MENTION_WID_MAX_LENGTH,@@ -45,6 +48,7 @@ export class SendLocationDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty({ example: -6.2088 })@@ -85,6 +89,7 @@ export class SendContactDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty({ maxLength: CONTACT_NAME_MAX_LENGTH })@@ -115,6 +120,7 @@ export class SendPollDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty({ description: 'Poll question / title', maxLength: 255, example: 'Where should we meet?' })@@ -166,6 +172,7 @@ export class ReplyMessageDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty()@@ -205,6 +212,7 @@ export class ForwardMessageDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })fromChatId!: string;@ApiProperty({ maxLength: CHAT_ID_MAX_LENGTH })@@ -212,6 +220,7 @@ export class ForwardMessageDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })toChatId!: string;@ApiProperty()@@ -227,6 +236,7 @@ export class ReactMessageDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty()@@ -252,6 +262,7 @@ export class DeleteMessageDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty()@@ -284,6 +295,7 @@ export class PinMessageDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty()@@ -315,6 +327,7 @@ export class VotePollDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty({ description: 'The poll creation message to vote on.' })@@ -343,6 +356,7 @@ export class ClickButtonDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty({ description: 'WhatsApp id of the business prompt message that offered the buttons.' })@@ -382,6 +396,7 @@ export class StarMessageDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty()@@ -404,6 +419,7 @@ export class UnpinMessageDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty()@@ -419,6 +435,7 @@ export class EditMessageDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty()diff --git a/src/modules/message/dto/send-message.dto.spec.ts b/src/modules/message/dto/send-message.dto.spec.tsindex ad51460bd..b3cfc31b3 100644--- a/src/modules/message/dto/send-message.dto.spec.ts+++ b/src/modules/message/dto/send-message.dto.spec.ts@@ -355,7 +355,7 @@ describe('string fields refuse a boolean or an object', () => {expect(contact.contactNumber).toBe('628999888777');expect(await validate(contact, GLOBAL_VALIDATION_OPTIONS)).toHaveLength(0);- expect(await validateDto(SendTextMessageDto, { chatId: 628123456789, text: 5 })).toHaveLength(0);+ expect(await validateDto(SendTextMessageDto, { chatId: '[email protected]', text: 5 })).toHaveLength(0);});it('still takes the same values spelled as strings', async () => {diff --git a/src/modules/message/dto/send-message.dto.ts b/src/modules/message/dto/send-message.dto.tsindex 4fbd867d7..2e997bf58 100644--- a/src/modules/message/dto/send-message.dto.ts+++ b/src/modules/message/dto/send-message.dto.ts@@ -10,6 +10,7 @@ import {IsBoolean,IsObject,Validate,+ Matches,} from 'class-validator';import { Type } from 'class-transformer';import { IsMentionWidConstraint } from './is-mention-wid.validator';@@ -119,6 +120,7 @@ export class SendTextMessageDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty({@@ -225,6 +227,7 @@ export class SendMediaMessageDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiPropertyOptional({diff --git a/src/modules/message/dto/send-template.dto.ts b/src/modules/message/dto/send-template.dto.tsindex fd6474d75..e7a15bcce 100644--- a/src/modules/message/dto/send-template.dto.ts+++ b/src/modules/message/dto/send-template.dto.ts@@ -9,9 +9,17 @@ import {MaxLength,IsBoolean,Validate,+ Matches,} from 'class-validator';import { ToStrictArray, ToStrictBoolean, ToStrictString } from '../../../common/utils/strict-boolean';-import { CHAT_ID_MAX_LENGTH, MENTIONS_DESCRIPTION, MENTIONS_MAX, MENTION_WID_MAX_LENGTH } from './send-message.dto';+import {+ CHAT_ID_MAX_LENGTH,+ CHAT_JID_MESSAGE,+ CHAT_JID_PATTERN,+ MENTIONS_DESCRIPTION,+ MENTIONS_MAX,+ MENTION_WID_MAX_LENGTH,+} from './send-message.dto';import { IsMentionWidConstraint } from './is-mention-wid.validator';export class SendTemplateMessageDto {@@ -24,6 +32,7 @@ export class SendTemplateMessageDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiPropertyOptional({diff --git a/src/modules/session/dto/send-chat-state.dto.ts b/src/modules/session/dto/send-chat-state.dto.tsindex fffc742b0..22c2ec4fa 100644--- a/src/modules/session/dto/send-chat-state.dto.ts+++ b/src/modules/session/dto/send-chat-state.dto.ts@@ -1,7 +1,7 @@import { ApiProperty } from '@nestjs/swagger';-import { IsIn, IsNotEmpty, IsString, MaxLength } from 'class-validator';+import { IsIn, IsNotEmpty, IsString, Matches, MaxLength } from 'class-validator';import type { ChatState } from '../../../engine/interfaces/whatsapp-engine.interface';-import { CHAT_ID_MAX_LENGTH } from '../../message/dto/send-message.dto';+import { CHAT_ID_MAX_LENGTH, CHAT_JID_MESSAGE, CHAT_JID_PATTERN } from '../../message/dto/send-message.dto';import { ToStrictString } from '../../../common/utils/strict-boolean';export class SendChatStateDto {@@ -17,6 +17,7 @@ export class SendChatStateDto {@IsString()@IsNotEmpty()@MaxLength(CHAT_ID_MAX_LENGTH)+ @Matches(CHAT_JID_PATTERN, { message: CHAT_JID_MESSAGE })chatId!: string;@ApiProperty({