Browse Source

fix(api): throw exception if message is blank or invalid recipients provided

pull/19/head
isra el 2 years ago
parent
commit
3ce839bbd5
  1. 20
      api/src/gateway/gateway.service.ts

20
api/src/gateway/gateway.service.ts

@ -103,6 +103,26 @@ 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
if (!message) {
throw new HttpException(
{
success: false,
error: 'Invalid message',
},
HttpStatus.BAD_REQUEST,
)
}
if (!Array.isArray(recipients) || recipients.length === 0) {
throw new HttpException(
{
success: false,
error: 'Invalid recipients',
},
HttpStatus.BAD_REQUEST,
)
}
// 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

Loading…
Cancel
Save