diff --git a/api/src/support/dto/create-support-message.dto.ts b/api/src/support/dto/create-support-message.dto.ts new file mode 100644 index 0000000..c1dbbba --- /dev/null +++ b/api/src/support/dto/create-support-message.dto.ts @@ -0,0 +1,49 @@ +import { + IsEmail, + IsEnum, + IsNotEmpty, + IsOptional, + IsString, +} from 'class-validator' + +export enum SupportCategory { + GENERAL = 'general', + TECHNICAL = 'technical', + BILLING_AND_PAYMENTS = 'billing-and-payments', + ACCOUNT_DELETION = 'account-deletion', + OTHER = 'other', +} + +export class CreateSupportMessageDto { + @IsOptional() + @IsString() + user?: string + + @IsNotEmpty() + @IsString() + name: string + + @IsNotEmpty() + @IsEmail() + email: string + + @IsOptional() + @IsString() + phone?: string + + @IsNotEmpty() + @IsEnum(SupportCategory) + category: SupportCategory + + @IsNotEmpty() + @IsString() + message: string + + @IsOptional() + @IsString() + ip?: string + + @IsOptional() + @IsString() + userAgent?: string +} diff --git a/api/src/support/schemas/support-message.schema.ts b/api/src/support/schemas/support-message.schema.ts new file mode 100644 index 0000000..a702f58 --- /dev/null +++ b/api/src/support/schemas/support-message.schema.ts @@ -0,0 +1,37 @@ +import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose' +import { Document, Types } from 'mongoose' +import { User } from 'src/users/schemas/user.schema' + +export type SupportMessageDocument = SupportMessage & Document + +@Schema({ timestamps: true }) +export class SupportMessage { + @Prop({ type: Types.ObjectId, ref: User.name }) + user: User + + @Prop() + name: string + + @Prop() + email: string + + @Prop() + phone: string + + @Prop() + category: string + + @Prop() + message: string + + @Prop() + ip: string + + @Prop() + userAgent: string + + @Prop({ default: 'RECEIVED' }) + type: string +} + +export const SupportMessageSchema = SchemaFactory.createForClass(SupportMessage)