Skip to content

Commit

Permalink
feat: Added support for send message to @lid
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Oct 29, 2024
1 parent 891c1ee commit 7dde87e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/controller/messageController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
}
Expand All @@ -61,6 +62,7 @@ export async function sendMessage(req: Request, res: Response) {
phone: '5521999999999',
isGroup: false,
isNewsletter: false,
isLid: false,
message: 'Hi from WPPConnect',
}
},
Expand All @@ -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',
Expand Down Expand Up @@ -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" }
Expand All @@ -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": "<base64> string"
Expand Down
4 changes: 3 additions & 1 deletion src/middleware/statusConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
7 changes: 6 additions & 1 deletion src/util/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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 {
Expand All @@ -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`);
}
}
Expand Down

0 comments on commit 7dde87e

Please sign in to comment.