Skip to content

Commit

Permalink
[core] Check session "name" length
Browse files Browse the repository at this point in the history
  • Loading branch information
devlikepro committed Aug 27, 2024
1 parent dc86405 commit 2d1859a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/structures/sessions.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
IsBoolean,
IsOptional,
IsString,
MaxLength,
ValidateNested,
} from 'class-validator';

Expand Down Expand Up @@ -154,6 +155,9 @@ export class SessionInfo extends SessionDTO {
engine?: any;
}

const MONGO_DB_NAME_LIMIT = 64;
const MONGO_DB_NAME_PREFIX_LEN = 'waha_noweb'.length;

export class SessionCreateRequest {
@ApiProperty({
example: 'default',
Expand All @@ -162,6 +166,7 @@ export class SessionCreateRequest {
})
@IsString()
@IsOptional()
@MaxLength(MONGO_DB_NAME_LIMIT - MONGO_DB_NAME_PREFIX_LEN)
name: string | undefined;

@ValidateNested()
Expand Down

0 comments on commit 2d1859a

Please sign in to comment.