mirror of
https://github.com/vernu/textbee.git
synced 2026-05-19 05:46:23 -04:00
chore(api): update sms schema
This commit is contained in:
@@ -5,6 +5,7 @@ import { GatewayController } from './gateway.controller'
|
||||
import { GatewayService } from './gateway.service'
|
||||
import { AuthModule } from '../auth/auth.module'
|
||||
import { UsersModule } from '../users/users.module'
|
||||
import { SMS, SMSSchema } from './schemas/sms.schema'
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -13,6 +14,10 @@ import { UsersModule } from '../users/users.module'
|
||||
name: Device.name,
|
||||
schema: DeviceSchema,
|
||||
},
|
||||
{
|
||||
name: SMS.name,
|
||||
schema: SMSSchema,
|
||||
},
|
||||
]),
|
||||
AuthModule,
|
||||
UsersModule,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
|
||||
import { Document, Types } from 'mongoose'
|
||||
import { Device } from './device.schema'
|
||||
import { SMSType } from '../sms-type.enum'
|
||||
|
||||
export type SMSDocument = SMS & Document
|
||||
|
||||
@@ -8,14 +9,47 @@ export type SMSDocument = SMS & Document
|
||||
export class SMS {
|
||||
_id?: Types.ObjectId
|
||||
|
||||
@Prop({ type: Types.ObjectId, ref: Device.name })
|
||||
@Prop({ type: Types.ObjectId, ref: Device.name, required: true })
|
||||
device: Device
|
||||
|
||||
@Prop({ type: String, required: true })
|
||||
message: string
|
||||
|
||||
@Prop({ type: String, required: true })
|
||||
to: string
|
||||
type: string
|
||||
|
||||
// fields for incoming messages
|
||||
@Prop({ type: String })
|
||||
sender: string
|
||||
|
||||
@Prop({ type: Date, default: Date.now })
|
||||
receivedAt: Date
|
||||
|
||||
// fields for outgoing messages
|
||||
@Prop({ type: String })
|
||||
recipient: string
|
||||
|
||||
@Prop({ type: Date, default: Date.now })
|
||||
requestedAt: Date
|
||||
|
||||
@Prop({ type: Date })
|
||||
sentAt: Date
|
||||
|
||||
@Prop({ type: Date })
|
||||
deliveredAt: Date
|
||||
|
||||
@Prop({ type: Date })
|
||||
failedAt: Date
|
||||
|
||||
// @Prop({ type: String })
|
||||
// failureReason: string
|
||||
|
||||
// @Prop({ type: String })
|
||||
// status: string
|
||||
|
||||
// misc metadata for debugging
|
||||
@Prop({ type: Object })
|
||||
metadata: Record<string, any>
|
||||
}
|
||||
|
||||
export const SMSSchema = SchemaFactory.createForClass(SMS)
|
||||
|
||||
4
api/src/gateway/sms-type.enum.ts
Normal file
4
api/src/gateway/sms-type.enum.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export enum SMSType {
|
||||
SENT = 'SENT',
|
||||
RECEIVED = 'RECEIVED',
|
||||
}
|
||||
Reference in New Issue
Block a user