import { Type } from "class-transformer"; import { IsNotEmpty, IsNotEmptyObject, IsOptional, IsString, MinLength, ValidateNested } from "class-validator"; import { MessageContentVO } from "../../conversation"; import { OutboundMessageCommand } from "./OutboundMessageCommand"; export class SendMessageCommand extends OutboundMessageCommand { static readonly commandName = "conversation.SendMessageCommand"; @IsString() @IsNotEmpty() public readonly conversationId: string; @IsString() @IsNotEmpty() public readonly senderId: string; @IsNotEmptyObject() @ValidateNested() @Type(() => MessageContentVO) readonly messageContent: MessageContentVO; @IsNotEmpty() @IsString() readonly platform: string; @IsNotEmpty() @IsString() readonly channelId: string; @IsNotEmpty() @IsString() readonly channelUserId: string; constructor({ tenantId, messageId, conversationId, senderId, messageContent, platform, channelId, channelUserId }: { tenantId: string; messageId: string; conversationId: string; senderId:string; messageContent:MessageContentVO; platform: string; channelId: string; channelUserId: string; }) { super({ commandName: SendMessageCommand.commandName, tenantId, messageId, }); this.conversationId = conversationId; this.senderId = senderId; this.messageContent = messageContent; this.platform = platform; this.channelId = channelId; this.channelUserId = channelUserId; } }