From 3294e82e204c81217d3b1a951f9e6580e9949f66 Mon Sep 17 00:00:00 2001 From: Saif Allah Khaled Date: Fri, 21 Jun 2024 15:16:00 +0300 Subject: [PATCH 1/5] fix: getChatById when sending @ number. --- src/controller/deviceController.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/controller/deviceController.ts b/src/controller/deviceController.ts index 25978471f1..36a5bbe308 100644 --- a/src/controller/deviceController.ts +++ b/src/controller/deviceController.ts @@ -377,7 +377,7 @@ export async function getChatById(req: Request, res: Response) { schema: 'NERDWHATS_AMERICA' } #swagger.parameters["phone"] = { - schema: '5521999999999' + schema: '5521999999999@c.us' } #swagger.parameters["isGroup"] = { schema: 'false' @@ -387,11 +387,9 @@ export async function getChatById(req: Request, res: Response) { const { isGroup } = req.query; try { - let result = {} as Chat; - if (isGroup) { - result = await req.client.getChatById(`${phone}@g.us`); - } else { - result = await req.client.getChatById(`${phone}@c.us`); + let result; + for (const contato of contactToArray(phone as string, isGroup)) { + result = await req.client.getNumberProfile(contato); } return res.status(200).json(result); From 66d125921d118ada3c844dd5d1e99b75f8e0810b Mon Sep 17 00:00:00 2001 From: Saif Allah Khaled Date: Fri, 21 Jun 2024 15:17:09 +0300 Subject: [PATCH 2/5] fix: getChatById when sending @ number. --- src/controller/deviceController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controller/deviceController.ts b/src/controller/deviceController.ts index 36a5bbe308..af480b0ecc 100644 --- a/src/controller/deviceController.ts +++ b/src/controller/deviceController.ts @@ -389,7 +389,7 @@ export async function getChatById(req: Request, res: Response) { try { let result; for (const contato of contactToArray(phone as string, isGroup)) { - result = await req.client.getNumberProfile(contato); + result = await req.client.getChatById(contato); } return res.status(200).json(result); From c73488fe8ba28a96f2b31d9942a1b26b0f3a45d2 Mon Sep 17 00:00:00 2001 From: Saifallak Date: Thu, 28 Nov 2024 17:32:31 +0200 Subject: [PATCH 3/5] fix lints. --- src/controller/deviceController.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/controller/deviceController.ts b/src/controller/deviceController.ts index 5f20572506..094c4d8ec7 100644 --- a/src/controller/deviceController.ts +++ b/src/controller/deviceController.ts @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Chat } from '@wppconnect-team/wppconnect'; import { Request, Response } from 'express'; import { contactToArray, unlinkAsync } from '../util/functions'; @@ -384,11 +383,11 @@ export async function getChatById(req: Request, res: Response) { } */ const { phone } = req.params; - const { isGroup } = req.query; + const { isGroup = false } = req.query; try { let result; - for (const contato of contactToArray(phone as string, isGroup)) { + for (const contato of contactToArray(phone as string, isGroup as boolean)) { result = await req.client.getChatById(contato); } From 2d770f3b1c0088d8228496844d4a253d9a7f3dc7 Mon Sep 17 00:00:00 2001 From: Saifallak Date: Thu, 28 Nov 2024 17:34:01 +0200 Subject: [PATCH 4/5] fix lints. --- src/controller/deviceController.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controller/deviceController.ts b/src/controller/deviceController.ts index 094c4d8ec7..3e59860932 100644 --- a/src/controller/deviceController.ts +++ b/src/controller/deviceController.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { Chat } from '@wppconnect-team/wppconnect'; import { Request, Response } from 'express'; import { contactToArray, unlinkAsync } from '../util/functions'; @@ -386,7 +387,7 @@ export async function getChatById(req: Request, res: Response) { const { isGroup = false } = req.query; try { - let result; + let result = {} as Chat; for (const contato of contactToArray(phone as string, isGroup as boolean)) { result = await req.client.getChatById(contato); } From 0de2e64de9f91b426ceb175b394f40e3f5e86eba Mon Sep 17 00:00:00 2001 From: Saifallak Date: Thu, 28 Nov 2024 17:41:34 +0200 Subject: [PATCH 5/5] Trigger Build