From bb974e10f5baf077758689496dc47f744e349bc2 Mon Sep 17 00:00:00 2001 From: Paulo Kramer Date: Thu, 18 Apr 2024 00:58:33 -0300 Subject: [PATCH 1/6] Added message status to the messaging-history.set --- src/api/models/message.model.ts | 1 + src/api/services/whatsapp/whatsapp.baileys.service.ts | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/api/models/message.model.ts b/src/api/models/message.model.ts index 893d1f2af..95cb55133 100644 --- a/src/api/models/message.model.ts +++ b/src/api/models/message.model.ts @@ -32,6 +32,7 @@ export class MessageRaw { source_reply_id?: string; chatwoot?: ChatwootMessage; contextInfo?: any; + status?: wa.StatusMessage | any; } type MessageRawBoolean = { diff --git a/src/api/services/whatsapp/whatsapp.baileys.service.ts b/src/api/services/whatsapp/whatsapp.baileys.service.ts index 6285250bb..82a301c02 100644 --- a/src/api/services/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/services/whatsapp/whatsapp.baileys.service.ts @@ -976,6 +976,15 @@ export class BaileysStartupService extends WAStartupService { continue; } + const status: Record = { + 0: 'ERROR', + 1: 'PENDING', + 2: 'SERVER_ACK', + 3: 'DELIVERY_ACK', + 4: 'READ', + 5: 'PLAYED', + }; + messagesRaw.push({ key: m.key, pushName: m.pushName || m.key.remoteJid.split('@')[0], @@ -984,6 +993,7 @@ export class BaileysStartupService extends WAStartupService { messageType: getContentType(m.message), messageTimestamp: m.messageTimestamp as number, owner: this.instance.name, + status: m.status ? status[m.status] : null, }); } From a4d1740754b651dbbc0063c8c25e08fb78000804 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Thu, 18 Apr 2024 12:53:55 -0300 Subject: [PATCH 2/6] fix: Adjusts in proxy on fetchAgent --- CHANGELOG.md | 5 +++++ src/api/services/whatsapp/whatsapp.baileys.service.ts | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8bf1cedd..215ebec0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 1.7.4 (develop) + +### Fixed +* Adjusts in proxy + # 1.7.3 (2024-04-18 12:07) ### Fixed diff --git a/src/api/services/whatsapp/whatsapp.baileys.service.ts b/src/api/services/whatsapp/whatsapp.baileys.service.ts index 732f82a08..2d0112234 100644 --- a/src/api/services/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/services/whatsapp/whatsapp.baileys.service.ts @@ -517,6 +517,7 @@ export class BaileysStartupService extends WAStartupService { const proxyUrl = 'http://' + proxyUrls[rand]; options = { agent: makeProxyAgent(proxyUrl), + fetchAgent: makeProxyAgent(proxyUrl), }; } catch (error) { this.localProxy.enabled = false; @@ -524,6 +525,7 @@ export class BaileysStartupService extends WAStartupService { } else { options = { agent: makeProxyAgent(this.localProxy.proxy), + fetchAgent: makeProxyAgent(this.localProxy.proxy), }; } } @@ -687,6 +689,7 @@ export class BaileysStartupService extends WAStartupService { const proxyUrl = 'http://' + proxyUrls[rand]; options = { agent: makeProxyAgent(proxyUrl), + fetchAgent: makeProxyAgent(proxyUrl), }; } catch (error) { this.localProxy.enabled = false; @@ -694,6 +697,7 @@ export class BaileysStartupService extends WAStartupService { } else { options = { agent: makeProxyAgent(this.localProxy.proxy), + fetchAgent: makeProxyAgent(this.localProxy.proxy), }; } } From 4dd5533202225125f9eb7de5c38ada38f932cfd4 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Thu, 18 Apr 2024 12:54:00 -0300 Subject: [PATCH 3/6] fix: Adjusts in proxy on fetchAgent --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 215ebec0f..b9fccb706 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # 1.7.4 (develop) ### Fixed -* Adjusts in proxy +* Adjusts in proxy on fetchAgent # 1.7.3 (2024-04-18 12:07) From 7449102d95c680afaa2202be9218b4cc38a97807 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Thu, 18 Apr 2024 17:31:05 -0300 Subject: [PATCH 4/6] fix: Recovering messages lost with redis cache --- .../whatsapp/whatsapp.baileys.service.ts | 2 +- src/cache/cacheengine.ts | 5 + views/manager-wip.hbs | 110 ------------------ 3 files changed, 6 insertions(+), 111 deletions(-) delete mode 100644 views/manager-wip.hbs diff --git a/src/api/services/whatsapp/whatsapp.baileys.service.ts b/src/api/services/whatsapp/whatsapp.baileys.service.ts index 3990c0e3f..d8d856a16 100644 --- a/src/api/services/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/services/whatsapp/whatsapp.baileys.service.ts @@ -151,7 +151,7 @@ export class BaileysStartupService extends WAStartupService { const cacheConf = this.configService.get('CACHE'); if ((cacheConf?.REDIS?.ENABLED && cacheConf?.REDIS?.URI !== '') || cacheConf?.LOCAL?.ENABLED) { - setTimeout(async () => { + setInterval(async () => { this.logger.info('Recovering messages'); this.messagesLostCache.keys().then((keys) => { keys.forEach(async (key) => { diff --git a/src/cache/cacheengine.ts b/src/cache/cacheengine.ts index 258a98c2b..dd3d18f18 100644 --- a/src/cache/cacheengine.ts +++ b/src/cache/cacheengine.ts @@ -1,8 +1,11 @@ import { ICache } from '../api/abstract/abstract.cache'; import { CacheConf, ConfigService } from '../config/env.config'; +import { Logger } from '../config/logger.config'; import { LocalCache } from './localcache'; import { RedisCache } from './rediscache'; +const logger = new Logger('Redis'); + export class CacheEngine { private engine: ICache; @@ -14,6 +17,8 @@ export class CacheEngine { } else if (cacheConf?.LOCAL?.ENABLED) { this.engine = new LocalCache(configService, module); } + + logger.info(`RedisCache initialized for ${module}`); } public getEngine() { diff --git a/views/manager-wip.hbs b/views/manager-wip.hbs deleted file mode 100644 index 59b0cd0f8..000000000 --- a/views/manager-wip.hbs +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - Instance Manager - - - -
- - - - - - - - - - - - - - - - {{#each instances}} - - - - - - - {{/each}} - -
Nome da InstânciaStatusAPI KeyAções
{{this.instance.instanceName}}{{this.instance.status}}{{this.instance.apikey}} - - -
-
- - - - - - - - - - - - \ No newline at end of file From 27f9ae1e5617521a94d7de77a66137a1db9dfb54 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Thu, 18 Apr 2024 17:31:10 -0300 Subject: [PATCH 5/6] fix: Recovering messages lost with redis cache --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9fccb706..a772d5b4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Fixed * Adjusts in proxy on fetchAgent +* Recovering messages lost with redis cache # 1.7.3 (2024-04-18 12:07) From c85619efcf2307b76001c9d957d988b1f986abb9 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Thu, 18 Apr 2024 17:33:09 -0300 Subject: [PATCH 6/6] fix: Recovering messages lost with redis cache --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a772d5b4a..fc11ef67c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Fixed * Adjusts in proxy on fetchAgent * Recovering messages lost with redis cache +* Log when init redis cache service # 1.7.3 (2024-04-18 12:07)