import {
  ArrayNotEmpty,
  IsArray,
  IsIn,
  IsMongoId,
  IsOptional,
  IsString,
  MaxLength,
} from "class-validator";

export class ShareMessageDto {
  // Conversations to share the entity into (one or many)
  @IsArray()
  @ArrayNotEmpty()
  @IsMongoId({ each: true })
  conversation_ids: string[];

  // What is being shared
  @IsIn(["challenge", "profile"])
  message_type: "challenge" | "profile";

  // Id of the challenge — required when message_type === 'challenge'
  @IsOptional()
  @IsMongoId()
  shared_challenge?: string;

  // Id of the user whose profile is shared — required when message_type === 'profile'
  @IsOptional()
  @IsMongoId()
  shared_profile?: string;

  // Optional note ("Add a message…")
  @IsOptional()
  @IsString()
  @MaxLength(2000)
  text?: string;
}
