|
|
@ -115,12 +115,6 @@ export class GatewayService { |
|
|
const message = smsData.message || smsData.smsBody |
|
|
const message = smsData.message || smsData.smsBody |
|
|
const recipients = smsData.recipients || smsData.receivers |
|
|
const recipients = smsData.recipients || smsData.receivers |
|
|
|
|
|
|
|
|
await this.billingService.canPerformAction( |
|
|
|
|
|
device.user.toString(), |
|
|
|
|
|
'send_sms', |
|
|
|
|
|
recipients.length, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
if (!message) { |
|
|
if (!message) { |
|
|
throw new HttpException( |
|
|
throw new HttpException( |
|
|
{ |
|
|
{ |
|
|
@ -141,6 +135,12 @@ export class GatewayService { |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await this.billingService.canPerformAction( |
|
|
|
|
|
device.user.toString(), |
|
|
|
|
|
'send_sms', |
|
|
|
|
|
recipients.length, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
// TODO: Implement a queue to send the SMS if recipients are too many
|
|
|
// TODO: Implement a queue to send the SMS if recipients are too many
|
|
|
|
|
|
|
|
|
let smsBatch: SMSBatch |
|
|
let smsBatch: SMSBatch |
|
|
@ -249,11 +249,6 @@ export class GatewayService { |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
await this.billingService.canPerformAction( |
|
|
|
|
|
device.user.toString(), |
|
|
|
|
|
'bulk_send_sms', |
|
|
|
|
|
body.messages.map((m) => m.recipients).flat().length, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
if ( |
|
|
!Array.isArray(body.messages) || |
|
|
!Array.isArray(body.messages) || |
|
|
@ -269,6 +264,12 @@ export class GatewayService { |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await this.billingService.canPerformAction( |
|
|
|
|
|
device.user.toString(), |
|
|
|
|
|
'bulk_send_sms', |
|
|
|
|
|
body.messages.map((m) => m.recipients).flat().length, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
const { messageTemplate, messages } = body |
|
|
const { messageTemplate, messages } = body |
|
|
|
|
|
|
|
|
const smsBatch = await this.smsBatchModel.create({ |
|
|
const smsBatch = await this.smsBatchModel.create({ |
|
|
@ -381,12 +382,6 @@ export class GatewayService { |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
await this.billingService.canPerformAction( |
|
|
|
|
|
device.user.toString(), |
|
|
|
|
|
'receive_sms', |
|
|
|
|
|
1, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
if ( |
|
|
(!dto.receivedAt && !dto.receivedAtInMillis) || |
|
|
(!dto.receivedAt && !dto.receivedAtInMillis) || |
|
|
!dto.sender || |
|
|
!dto.sender || |
|
|
@ -402,6 +397,12 @@ export class GatewayService { |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await this.billingService.canPerformAction( |
|
|
|
|
|
device.user.toString(), |
|
|
|
|
|
'receive_sms', |
|
|
|
|
|
1, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
const receivedAt = dto.receivedAtInMillis |
|
|
const receivedAt = dto.receivedAtInMillis |
|
|
? new Date(dto.receivedAtInMillis) |
|
|
? new Date(dto.receivedAtInMillis) |
|
|
: dto.receivedAt |
|
|
: dto.receivedAt |
|
|
|