Skip to content
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

Merged
merged 5 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ export async function nextBatchJobLookups({
lastCount,
steps
);
console.log("scrub-bad-mobilenums error: ", err);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.error

await r
.knex("job_request")
.where("id", job.id)
Expand Down
26 changes: 14 additions & 12 deletions src/extensions/service-vendors/twilio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be an array instead of parentheses?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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
Twilio wants types.fields as a comma separated string. That parentheses is awkward though

}
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;
Expand Down
Loading