From 395715f68f2b3ab575de538241d3fce9e9458af3 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 24 May 2024 11:11:14 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=B7=B4=E8=A5=BF=E5=8F=B7=E7=A0=81?= =?UTF-8?q?=E8=A7=84=E5=88=99:=20=E5=88=A0=E9=99=A4=E5=9B=BD=E5=AE=B6?= =?UTF-8?q?=E5=9C=B0=E5=8C=BA=E7=A0=81=E5=90=8E=E9=9D=A2=E7=9A=849?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/channel/whatsappUtils.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/channel/whatsappUtils.js b/src/channel/whatsappUtils.js index 6629ee2..68a6480 100644 --- a/src/channel/whatsappUtils.js +++ b/src/channel/whatsappUtils.js @@ -681,6 +681,7 @@ export const handleNotification = (title, _options) => { * - Make sure to remove any leading 0s or special calling codes. * - All phone numbers in Argentina (country code "54") should have a "9" between the country code and area code. The prefix "15" must be removed so the final number will have 13 digits total: +54 9 XXX XXX XXXX * - Phone numbers in Mexico (country code "52") need to have "1" after "+52", even if they're Nextel numbers. + * - 巴西号码: 13位的话删除国家地区码后面的`9` */ export const phoneNumberToWAID = (input) => { // Remove any non-digit characters @@ -692,6 +693,7 @@ export const phoneNumberToWAID = (input) => { const countryCode = cleanedInput.slice(0, 2); const isArgentina = countryCode === '54'; const isMexico = countryCode === '52'; + const isBrazil = countryCode === '55'; // if (!isArgentina && !isMexico) { if (!isArgentina) { @@ -715,6 +717,10 @@ export const phoneNumberToWAID = (input) => { // formattedNumber = formattedNumber.replace(/^52 ?0/, '52'); // Insert "1" after the country code // formattedNumber = `52 1 ${formattedNumber.slice(2)}`; + } else if (isBrazil) { + if (cleanedInput.length > 12) { + formattedNumber = cleanedInput.slice(0, 4) + cleanedInput.slice(-8); + } } // Remove any non-digit characters