mirror of
https://github.com/vernu/textbee.git
synced 2026-02-20 15:44:31 -05:00
chore(api): add missing dto and schema
This commit is contained in:
49
api/src/support/dto/create-support-message.dto.ts
Normal file
49
api/src/support/dto/create-support-message.dto.ts
Normal file
@@ -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
|
||||
}
|
||||
37
api/src/support/schemas/support-message.schema.ts
Normal file
37
api/src/support/schemas/support-message.schema.ts
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user