mirror of
https://github.com/vernu/textbee.git
synced 2026-05-19 05:46:23 -04:00
fix(api): throw exception if message is blank or invalid recipients provided
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user