feat: setup the attachment to the passenger api

This commit is contained in:
Nathnael
2026-07-18 09:44:14 +00:00
parent 4f043ea4bf
commit bdcd5e957e
12 changed files with 781 additions and 116 deletions

View File

@@ -32,12 +32,19 @@ export class CreateConversationDto {
initialMessage!: string;
}
/**
* Text is optional across the send DTOs because a message may be nothing but
* attachments. "Neither text nor files" is rejected in the service rather than
* here — the validator can't see the multipart file parts.
*/
export class SendMessageDto {
@ApiProperty({ description: 'Message text.' })
@ApiPropertyOptional({
description: 'Message text. Optional only when attachments are present.',
})
@IsOptional()
@IsString()
@MinLength(1)
@MaxLength(4000)
text!: string;
text?: string;
}
export class CreateGuestConversationDto {
@@ -79,11 +86,13 @@ export class GuestSendMessageDto {
@Length(8, 120)
guestId!: string;
@ApiProperty({ description: 'Message text.' })
@ApiPropertyOptional({
description: 'Message text. Optional only when attachments are present.',
})
@IsOptional()
@IsString()
@MinLength(1)
@MaxLength(4000)
text!: string;
text?: string;
}
export class GuestIdBodyDto {
@@ -99,11 +108,13 @@ export class DeviceSendMessageDto {
@Length(8, 120)
deviceId!: string;
@ApiProperty({ description: 'Message text.' })
@ApiPropertyOptional({
description: 'Message text. Optional only when attachments are present.',
})
@IsOptional()
@IsString()
@MinLength(1)
@MaxLength(4000)
text!: string;
text?: string;
}
export class DeviceIdBodyDto {
@@ -145,3 +156,38 @@ export class ListConversationsQueryDto {
@Max(100)
limit?: number;
}
/** Default page size for a thread — roughly two screens of bubbles. */
export const SUPPORT_MESSAGES_DEFAULT_LIMIT = 30;
export const SUPPORT_MESSAGES_MAX_LIMIT = 100;
export class ListMessagesQueryDto {
@ApiPropertyOptional({
description:
"Opaque cursor from a previous response's `nextCursor`. Returns the page " +
'of messages immediately OLDER than the cursor. Omit for the newest page.',
})
@IsOptional()
@IsString()
before?: string;
@ApiPropertyOptional({
minimum: 1,
maximum: SUPPORT_MESSAGES_MAX_LIMIT,
default: SUPPORT_MESSAGES_DEFAULT_LIMIT,
})
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
@Max(SUPPORT_MESSAGES_MAX_LIMIT)
limit?: number;
}
/** Query form of {@link ListMessagesQueryDto} for the device-scoped thread. */
export class DeviceThreadQueryDto extends ListMessagesQueryDto {
@ApiProperty({ description: 'Client device id (localStorage).' })
@IsString()
@Length(8, 120)
deviceId!: string;
}