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

This commit is contained in:
isra el
2024-05-14 04:44:59 +03:00
parent 38652c3a82
commit 3ce839bbd5

View File

@@ -103,6 +103,26 @@ export class GatewayService {
const message = smsData.message || smsData.smsBody
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
let smsBatch: SMSBatch