Browse Source

feat(api): track sent sms count per device

pull/4/head
isra el 2 years ago
parent
commit
7eb78b72f2
  1. 6
      api/src/gateway/gateway.service.ts
  2. 3
      api/src/gateway/schemas/device.schema.ts

6
api/src/gateway/gateway.service.ts

@ -95,6 +95,12 @@ export class GatewayService {
const response = await firebaseAdmin
.messaging()
.sendToDevice(device.fcmToken, payload, { priority: 'high' })
this.deviceModel.findByIdAndUpdate(
deviceId,
{ $inc: { sentSMSCount: 1 } },
{ new: true },
)
return response
} catch (e) {
throw new HttpException(

3
api/src/gateway/schemas/device.schema.ts

@ -43,6 +43,9 @@ export class Device {
@Prop({ type: Number })
appVersionCode: number
@Prop({ type: Number, default: 0 })
sentSMSCount: number
}
export const DeviceSchema = SchemaFactory.createForClass(Device)
Loading…
Cancel
Save