From 55e36f24a5d578acb9a0802e0bd8665d0815f3f6 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Sun, 11 Jun 2023 11:04:52 -0300 Subject: [PATCH] feat: Route to fetch all privacy settings --- CHANGELOG.md | 1 + src/whatsapp/controllers/chat.controller.ts | 4 ++++ src/whatsapp/routers/chat.router.ts | 10 ++++++++++ src/whatsapp/services/whatsapp.service.ts | 4 ++++ 4 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d6ea723..52879eee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Improved fetch instances endpoint, now it also fetch other instances even if they are not connected * Added conversion of audios for sending recorded audio, now it is possible to send mp3 audios and not just ogg * Route to fetch all groups that the connection is part of +* Route to fetch all privacy settings ### Fixed diff --git a/src/whatsapp/controllers/chat.controller.ts b/src/whatsapp/controllers/chat.controller.ts index da0d04c2..78629565 100644 --- a/src/whatsapp/controllers/chat.controller.ts +++ b/src/whatsapp/controllers/chat.controller.ts @@ -63,6 +63,10 @@ export class ChatController { return await this.waMonitor.waInstances[instanceName].fetchChats(); } + public async fetchPrivacySettings({ instanceName }: InstanceDto) { + return await this.waMonitor.waInstances[instanceName].fetchPrivacySettings(); + } + public async getBusinessProfile( { instanceName }: InstanceDto, data: ProfilePictureDto, diff --git a/src/whatsapp/routers/chat.router.ts b/src/whatsapp/routers/chat.router.ts index 2cbeaac3..b07ebc0d 100644 --- a/src/whatsapp/routers/chat.router.ts +++ b/src/whatsapp/routers/chat.router.ts @@ -140,6 +140,16 @@ export class ChatRouter extends RouterBroker { return res.status(HttpStatus.OK).json(response); }) // Profile routes + .get(this.routerPath('fetchPrivacySettings'), ...guards, async (req, res) => { + const response = await this.dataValidate({ + request: req, + schema: null, + ClassRef: InstanceDto, + execute: (instance) => chatController.fetchPrivacySettings(instance), + }); + + return res.status(HttpStatus.OK).json(response); + }) .post(this.routerPath('getBusinessProfile'), ...guards, async (req, res) => { const response = await this.dataValidate({ request: req, diff --git a/src/whatsapp/services/whatsapp.service.ts b/src/whatsapp/services/whatsapp.service.ts index 4441302b..5cdc36f0 100644 --- a/src/whatsapp/services/whatsapp.service.ts +++ b/src/whatsapp/services/whatsapp.service.ts @@ -1475,6 +1475,10 @@ export class WAStartupService { return await this.repository.chat.find({ where: { owner: this.instance.wuid } }); } + public async fetchPrivacySettings() { + return await this.client.fetchPrivacySettings(); + } + public async getBusinessProfile(number: string) { try { let jid;