fix: do not store failed twilio api responses on db
This commit is contained in:
parent
348260931e
commit
96bad31317
2 changed files with 9 additions and 3 deletions
|
|
@ -130,8 +130,8 @@ async function updateCustomer (id, data, userToken) {
|
||||||
.then(res => updateSubscriberData(id, res, userToken))
|
.then(res => updateSubscriberData(id, res, userToken))
|
||||||
.catch(logger.error)
|
.catch(logger.error)
|
||||||
}
|
}
|
||||||
invalidateCustomerNotifications(id, formattedData)
|
invalidateCustomerNotifications(id, formattedData)
|
||||||
return getCustomerById(id)
|
return getCustomerById(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -587,7 +587,7 @@ function formatSubscriberInfo(customer) {
|
||||||
const subscriberInfo = customer.subscriberInfo
|
const subscriberInfo = customer.subscriberInfo
|
||||||
if(!subscriberInfo) return customer
|
if(!subscriberInfo) return customer
|
||||||
const result = subscriberInfo.result
|
const result = subscriberInfo.result
|
||||||
if(subscriberInfo.status !== 'successful' || _.isEmpty(result)) return customer
|
if(_.isEmpty(result)) return _.omit(['subscriberInfo'], customer)
|
||||||
|
|
||||||
const name = _.get('belongs_to.name')(result)
|
const name = _.get('belongs_to.name')(result)
|
||||||
const street = _.get('current_addresses[0].street_line_1')(result)
|
const street = _.get('current_addresses[0].street_line_1')(result)
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,12 @@ function getLookup (account, number) {
|
||||||
.fetch({ addOns: ['lamassu_ekata'] })
|
.fetch({ addOns: ['lamassu_ekata'] })
|
||||||
})
|
})
|
||||||
.then(info => info.addOns.results['lamassu_ekata'])
|
.then(info => info.addOns.results['lamassu_ekata'])
|
||||||
|
.then(info => {
|
||||||
|
if (info.status !== 'successful') {
|
||||||
|
throw new Error(`Twilio error: ${info.message}`)
|
||||||
|
}
|
||||||
|
return info
|
||||||
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
if (_.includes(err.code, BAD_NUMBER_CODES)) {
|
if (_.includes(err.code, BAD_NUMBER_CODES)) {
|
||||||
const badNumberError = new Error(err.message)
|
const badNumberError = new Error(err.message)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue