From 9a5dbe055e68de80c1d8babe90746cd262aa05a7 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Fri, 8 Dec 2023 18:44:52 -0300 Subject: [PATCH] fix: adjusts in connection --- src/config/env.config.ts | 8 -------- src/dev-env.yml | 4 ---- src/whatsapp/services/whatsapp.service.ts | 13 +++++++++++++ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/config/env.config.ts b/src/config/env.config.ts index dcb90fbc..42c8826a 100644 --- a/src/config/env.config.ts +++ b/src/config/env.config.ts @@ -78,10 +78,6 @@ export type Websocket = { ENABLED: boolean; }; -export type Chatwoot = { - USE_REPLY_ID: boolean; -}; - export type EventsWebhook = { APPLICATION_STARTUP: boolean; QRCODE_UPDATED: boolean; @@ -154,7 +150,6 @@ export interface Env { TYPEBOT: Typebot; AUTHENTICATION: Auth; PRODUCTION?: Production; - CHATWOOT?: Chatwoot; } export type Key = keyof Env; @@ -323,9 +318,6 @@ export class ConfigService { SECRET: process.env.AUTHENTICATION_JWT_SECRET || 'L=0YWt]b2w[WF>#>:&E`', }, }, - CHATWOOT: { - USE_REPLY_ID: process.env?.USE_REPLY_ID === 'true', - }, }; } } diff --git a/src/dev-env.yml b/src/dev-env.yml index b2a2e521..cefdcbeb 100644 --- a/src/dev-env.yml +++ b/src/dev-env.yml @@ -164,7 +164,3 @@ AUTHENTICATION: JWT: EXPIRIN_IN: 0 # seconds - 3600s === 1h | zero (0) - never expires SECRET: L=0YWt]b2w[WF>#>:&E` - -# Configure to chatwoot -CHATWOOT: - USE_REPLY_ID: false diff --git a/src/whatsapp/services/whatsapp.service.ts b/src/whatsapp/services/whatsapp.service.ts index 630c6a27..99b4ab32 100644 --- a/src/whatsapp/services/whatsapp.service.ts +++ b/src/whatsapp/services/whatsapp.service.ts @@ -17,6 +17,7 @@ import makeWASocket, { getContentType, getDevice, GroupMetadata, + isJidBroadcast, isJidGroup, isJidUser, makeCacheableSignalKeyStore, @@ -1333,6 +1334,12 @@ export class WAStartupService { qrTimeout: 40_000, defaultQueryTimeoutMs: undefined, emitOwnEvents: false, + shouldIgnoreJid: (jid) => { + const isGroupJid = this.localSettings.groups_ignore && isJidGroup(jid); + const isBroadcast = !this.localSettings.read_status && isJidBroadcast(jid); + + return isGroupJid || isBroadcast; + }, msgRetryCounterCache: this.msgRetryCounterCache, getMessage: async (key) => (await this.getMessage(key)) as Promise, generateHighQualityLinkPreview: true, @@ -1414,6 +1421,12 @@ export class WAStartupService { qrTimeout: 40_000, defaultQueryTimeoutMs: undefined, emitOwnEvents: false, + shouldIgnoreJid: (jid) => { + const isGroupJid = this.localSettings.groups_ignore && isJidGroup(jid); + const isBroadcast = !this.localSettings.read_status && isJidBroadcast(jid); + + return isGroupJid || isBroadcast; + }, msgRetryCounterCache: this.msgRetryCounterCache, getMessage: async (key) => (await this.getMessage(key)) as Promise, generateHighQualityLinkPreview: true,