|
|
@ -1,6 +1,7 @@ |
|
|
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose' |
|
|
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose' |
|
|
import { Document, Types } from 'mongoose' |
|
|
import { Document, Types } from 'mongoose' |
|
|
import { Device } from './device.schema' |
|
|
import { Device } from './device.schema' |
|
|
|
|
|
import { SMSType } from '../sms-type.enum' |
|
|
|
|
|
|
|
|
export type SMSDocument = SMS & Document |
|
|
export type SMSDocument = SMS & Document |
|
|
|
|
|
|
|
|
@ -8,14 +9,47 @@ export type SMSDocument = SMS & Document |
|
|
export class SMS { |
|
|
export class SMS { |
|
|
_id?: Types.ObjectId |
|
|
_id?: Types.ObjectId |
|
|
|
|
|
|
|
|
@Prop({ type: Types.ObjectId, ref: Device.name }) |
|
|
|
|
|
|
|
|
@Prop({ type: Types.ObjectId, ref: Device.name, required: true }) |
|
|
device: Device |
|
|
device: Device |
|
|
|
|
|
|
|
|
@Prop({ type: String, required: true }) |
|
|
@Prop({ type: String, required: true }) |
|
|
message: string |
|
|
message: string |
|
|
|
|
|
|
|
|
@Prop({ type: String, required: true }) |
|
|
@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) |
|
|
export const SMSSchema = SchemaFactory.createForClass(SMS) |