fix(api): return error message if sms is not sent due to fcm failure

This commit is contained in:
isra el
2024-10-17 09:50:04 +03:00
parent 0991db5ab8
commit b3d3389dca

View File

@@ -185,9 +185,20 @@ export class GatewayService {
console.log(response)
if (response.successCount === 0) {
throw new HttpException(
{
success: false,
error: 'Failed to send SMS',
additionalInfo: response,
},
HttpStatus.BAD_REQUEST,
)
}
this.deviceModel
.findByIdAndUpdate(deviceId, {
$inc: { sentSMSCount: recipients.length },
$inc: { sentSMSCount: response.successCount },
})
.exec()
.catch((e) => {