fix error responses for sms

This commit is contained in:
Dave Horton
2021-09-22 10:54:36 -04:00
parent 862405c232
commit ac263de729

View File

@@ -60,9 +60,19 @@ class TaskMessage extends Task {
return res.sendStatus(404);
}
if (url) {
const post = bent(url, 'POST', 'json', 201);
const post = bent(url, 'POST', 'json', 201, 480);
this.logger.info({payload, url}, 'Message:exec sending outbound SMS');
const response = await post(relativeUrl, payload);
if (response.smpp_err_code) {
this.logger.info({response}, 'Error sending SMS');
if (cs.callInfo.res) {
res.status(480).json({
...response,
sid: cs.callInfo.messageSid
});
}
}
else {
this.logger.info({response}, 'Successfully sent SMS');
if (cs.callInfo.res) {
this.logger.info('Message:exec sending 200 OK response to HTTP POST from api server');
@@ -71,6 +81,7 @@ class TaskMessage extends Task {
providerResponse: response
});
}
}
// TODO: action Hook
}