|
|
@ -1,7 +1,11 @@
|
|
|
|
export function normalizeUserIdentifier(input: string): string {
|
|
|
|
export function normalizeUserIdentifier(input: string): string {
|
|
|
|
|
|
|
|
console.log('Normalizing user identifier:', input);
|
|
|
|
|
|
|
|
|
|
|
|
// Handle JID format (12345678@s.whatsapp.net)
|
|
|
|
// Handle JID format (12345678@s.whatsapp.net)
|
|
|
|
if (input.includes('@s.whatsapp.net')) {
|
|
|
|
if (input.includes('@s.whatsapp.net')) {
|
|
|
|
return input; // Return full JID
|
|
|
|
const [phone, domain] = input.split('@');
|
|
|
|
|
|
|
|
const cleanPhone = phone.replace(/\D/g, '');
|
|
|
|
|
|
|
|
return `${cleanPhone}@${domain}`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Remove @ prefix if present
|
|
|
|
// Remove @ prefix if present
|
|
|
@ -15,7 +19,9 @@ export function normalizeUserIdentifier(input: string): string {
|
|
|
|
throw new Error('Número de teléfono inválido');
|
|
|
|
throw new Error('Número de teléfono inválido');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return `${phoneNumber}@s.whatsapp.net`;
|
|
|
|
const jid = `${phoneNumber}@s.whatsapp.net`;
|
|
|
|
|
|
|
|
console.log('Normalized JID:', jid);
|
|
|
|
|
|
|
|
return jid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function extractUserFromJid(jid: string): string {
|
|
|
|
export function extractUserFromJid(jid: string): string {
|
|
|
|