-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Scrubber #2471
Fix Scrubber #2471
Changes from 2 commits
6407b60
7190805
c0415a6
710fe1d
3364e9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -633,44 +633,46 @@ export async function getContactInfo({ | |
return {}; | ||
} | ||
const twilio = await exports.getTwilio(organization); | ||
const types = ["carrier"]; | ||
const types = { fields: "line_type_intelligence" }; | ||
if (lookupName) { | ||
// caller-name is more expensive | ||
types.push("caller-name"); | ||
types.fields = ("line_type_intelligence,caller-name"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be an array instead of parentheses? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oddly enough, no: https://www.twilio.com/docs/lookup/v2-api#code-lookup-with-data-packages |
||
} | ||
const contactInfo = { | ||
contact_number: contactNumber, | ||
organization_id: organization.id, | ||
service: "twilio" | ||
}; | ||
try { | ||
const phoneNumber = await twilio.lookups.v1 | ||
const phoneNumber = await twilio.lookups.v2 | ||
.phoneNumbers(contactNumber) | ||
.fetch({ type: types }); | ||
.fetch(types); | ||
|
||
if (phoneNumber.carrier) { | ||
contactInfo.carrier = phoneNumber.carrier.name; | ||
if (phoneNumber.lineTypeIntelligence.carrier_name) { | ||
contactInfo.carrier = phoneNumber.lineTypeIntelligence.carrier_name; | ||
} | ||
if (phoneNumber.carrier.error_code) { | ||
if (phoneNumber.lineTypeIntelligence.error_code) { | ||
// e.g. 60600: Unprovisioned or Out of Coverage | ||
contactInfo.status_code = -2; | ||
contactInfo.last_error_code = phoneNumber.carrier.error_code; | ||
contactInfo.last_error_code = phoneNumber.lineTypeIntelligence.error_code; | ||
} else if ( | ||
phoneNumber.carrier.type && | ||
phoneNumber.carrier.type === "landline" | ||
// mobile or landline | ||
phoneNumber.lineTypeIntelligence.type && | ||
phoneNumber.lineTypeIntelligence.type === "landline" | ||
) { | ||
// landline (not mobile or voip) | ||
contactInfo.status_code = -1; | ||
} else if ( | ||
// example: US | ||
phoneNumber.countryCode && | ||
getConfig("PHONE_NUMBER_COUNTRY", organization) && | ||
getConfig("PHONE_NUMBER_COUNTRY", organization) !== | ||
phoneNumber.countryCode | ||
) { | ||
contactInfo.status_code = -3; // wrong country | ||
} else if ( | ||
phoneNumber.carrier.type && | ||
phoneNumber.carrier.type !== "landline" | ||
phoneNumber.lineTypeIntelligence.type && | ||
phoneNumber.lineTypeIntelligence.type !== "landline" | ||
) { | ||
// mobile, voip | ||
contactInfo.status_code = 1; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.error