Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs(session): publish the proxyUrl and muteUntil bounds

Yudhi Armyndharis1bf5d9564415
diff --git a/src/modules/session/dto/create-session.dto.spec.ts b/src/modules/session/dto/create-session.dto.spec.ts
index 64d1e0ed9..b545e6228 100644
--- a/src/modules/session/dto/create-session.dto.spec.ts
+++ b/src/modules/session/dto/create-session.dto.spec.ts
@@ -1,4 +1,5 @@
import { BadRequestException, ValidationPipe } from '@nestjs/common';
+import { DECORATORS } from '@nestjs/swagger';
import { validateSync } from 'class-validator';
import { plainToInstance } from 'class-transformer';
import { GLOBAL_VALIDATION_OPTIONS } from '../../../config/app-validation';
@@ -35,6 +36,13 @@ describe('CreateSessionDto proxyUrl validation', () => {
it('allows an omitted proxyUrl (optional)', () => {
expect(validateSync(plainToInstance(CreateSessionDto, { name: 'my-bot' }))).toHaveLength(0);
});
+
+ // @nestjs/swagger derives no bound from @MaxCodePoints, so the decorator has to state it.
+ it('publishes the 255 code point cap', () => {
+ const published = Reflect.getMetadata(DECORATORS.API_MODEL_PROPERTIES, CreateSessionDto.prototype, 'proxyUrl') as
+ { maxLength?: number } | undefined;
+ expect(published?.maxLength).toBe(255);
+ });
});
describe('CreateSessionDto config validation', () => {
diff --git a/src/modules/session/dto/create-session.dto.ts b/src/modules/session/dto/create-session.dto.ts
index c8ac22f0a..1a5670233 100644
--- a/src/modules/session/dto/create-session.dto.ts
+++ b/src/modules/session/dto/create-session.dto.ts
@@ -49,6 +49,7 @@ export class CreateSessionDto {
'start then times out (~30s → 504 Gateway Timeout); on Baileys the start succeeds and the session ' +
'keeps retrying the connection. Leave unset unless your network cannot reach WhatsApp directly. ' +
'Setting it requires an ADMIN key (403 otherwise).',
+ maxLength: 255,
})
@IsOptional()
@IsString()
diff --git a/src/modules/session/dto/mute-chat.dto.spec.ts b/src/modules/session/dto/mute-chat.dto.spec.ts
new file mode 100644
index 000000000..940914c53
--- /dev/null
+++ b/src/modules/session/dto/mute-chat.dto.spec.ts
@@ -0,0 +1,13 @@
+import { DECORATORS } from '@nestjs/swagger';
+import { MuteChatDto } from './mute-chat.dto';
+
+describe('MuteChatDto published schema', () => {
+ // @nestjs/swagger derives nothing from @IsInt/@Min, so the decorator has to state both.
+ it('publishes muteUntil as a nullable integer of at least 1', () => {
+ expect(Reflect.getMetadata(DECORATORS.API_MODEL_PROPERTIES, MuteChatDto.prototype, 'muteUntil')).toMatchObject({
+ type: 'integer',
+ nullable: true,
+ minimum: 1,
+ });
+ });
+});
diff --git a/src/modules/session/dto/mute-chat.dto.ts b/src/modules/session/dto/mute-chat.dto.ts
index b9d49bd69..daf01014e 100644
--- a/src/modules/session/dto/mute-chat.dto.ts
+++ b/src/modules/session/dto/mute-chat.dto.ts
@@ -23,8 +23,9 @@ export class MuteChatDto {
'Milliseconds, not seconds: a seconds-scale value is an instant in 1970, so the mute expires ' +
'immediately while the request still answers 200.',
example: 1800000000000,
- type: Number,
+ type: 'integer',
nullable: true,
+ minimum: 1,
})
// `null` is a real instruction (unmute), so it skips the numeric checks rather than failing them.
// A missing field is NOT null, so it still falls through to @IsInt and is rejected with a 400.