From 7dde87ea7e885dd977bb244a8b0c92248f12815f Mon Sep 17 00:00:00 2001 From: icleitoncosta Date: Tue, 29 Oct 2024 12:38:14 -0300 Subject: [PATCH] feat: Added support for send message to @lid --- src/controller/messageController.ts | 5 +++++ src/middleware/statusConnection.ts | 4 +++- src/util/functions.ts | 7 ++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/controller/messageController.ts b/src/controller/messageController.ts index e39b2a3789..7f83b585a7 100644 --- a/src/controller/messageController.ts +++ b/src/controller/messageController.ts @@ -51,6 +51,7 @@ export async function sendMessage(req: Request, res: Response) { phone: { type: "string" }, isGroup: { type: "boolean" }, isNewsletter: { type: "boolean" }, + isLid: { type: "boolean" }, message: { type: "string" }, options: { type: "object" }, } @@ -61,6 +62,7 @@ export async function sendMessage(req: Request, res: Response) { phone: '5521999999999', isGroup: false, isNewsletter: false, + isLid: false, message: 'Hi from WPPConnect', } }, @@ -69,6 +71,7 @@ export async function sendMessage(req: Request, res: Response) { phone: '5521999999999', isGroup: false, isNewsletter: false, + isLid: false, message: 'Hi from WPPConnect with reply', options: { quotedMsg: 'true_...@c.us_3EB01DE65ACC6_out', @@ -173,6 +176,7 @@ export async function sendFile(req: Request, res: Response) { "phone": { type: "string" }, "isGroup": { type: "boolean" }, "isNewsletter": { type: "boolean" }, + "isLid": { type: "boolean" }, "filename": { type: "string" }, "caption": { type: "string" }, "base64": { type: "string" } @@ -184,6 +188,7 @@ export async function sendFile(req: Request, res: Response) { "phone": "5521999999999", "isGroup": false, "isNewsletter": false, + "isLid": false, "filename": "file name lol", "caption": "caption for my file", "base64": " string" diff --git a/src/middleware/statusConnection.ts b/src/middleware/statusConnection.ts index 3de7a65b5c..f0e3c7592f 100644 --- a/src/middleware/statusConnection.ts +++ b/src/middleware/statusConnection.ts @@ -31,13 +31,15 @@ export default async function statusConnection( const localArr = contactToArray( req.body.phone || [], req.body.isGroup, - req.body.isNewsletter + req.body.isNewsletter, + req.body.isLid ); let index = 0; for (const contact of localArr) { if (req.body.isGroup || req.body.isNewsletter) { localArr[index] = contact; } else if (numbers.indexOf(contact) < 0) { + console.log(contact); const profile: any = await req.client .checkNumberStatus(contact) .catch((error) => console.log(error)); diff --git a/src/util/functions.ts b/src/util/functions.ts index 13dddfb669..fc4ce9af53 100644 --- a/src/util/functions.ts +++ b/src/util/functions.ts @@ -46,7 +46,8 @@ if (config?.websocket?.uploadS3) { export function contactToArray( number: any, isGroup?: boolean, - isNewsletter?: boolean + isNewsletter?: boolean, + isLid?: boolean ) { const localArr: any = []; if (Array.isArray(number)) { @@ -57,6 +58,8 @@ export function contactToArray( if (contact !== '') if (isGroup) (localArr as any).push(`${contact}@g.us`); else if (isNewsletter) (localArr as any).push(`${contact}@newsletter`); + else if (isLid || contact.length > 14) + (localArr as any).push(`${contact}@lid`); else (localArr as any).push(`${contact}@c.us`); } } else { @@ -68,6 +71,8 @@ export function contactToArray( if (contact !== '') if (isGroup) (localArr as any).push(`${contact}@g.us`); else if (isNewsletter) (localArr as any).push(`${contact}@newsletter`); + else if (isLid || contact.length > 14) + (localArr as any).push(`${contact}@lid`); else (localArr as any).push(`${contact}@c.us`); } }