From 79cadadcc72b7d7057b39d80685aa27918dd4eb8 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Wed, 26 Jun 2024 15:38:04 -0300 Subject: [PATCH] chore: Update group metadata cache (#GI234) - Updated the group metadata cache to improve performance. - Added verbose logging for cache updates and requests. - Affected file: `whatsapp.baileys.service.ts`. Please note that this change does not alter the functionality or behavior of the application. It is a maintenance task to optimize cache management. --- src/api/services/channels/whatsapp.baileys.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/services/channels/whatsapp.baileys.service.ts b/src/api/services/channels/whatsapp.baileys.service.ts index bdb45d0a..b5ea5d3c 100644 --- a/src/api/services/channels/whatsapp.baileys.service.ts +++ b/src/api/services/channels/whatsapp.baileys.service.ts @@ -3154,6 +3154,8 @@ export class BaileysStartupService extends ChannelStartupService { private async updateGroupMetadataCache(groupJid: string) { try { const meta = await this.client.groupMetadata(groupJid); + + this.logger.verbose(`Updating cache for group: ${groupJid}`); await groupMetadataCache.set(groupJid, { timestamp: Date.now(), data: meta, @@ -3170,6 +3172,7 @@ export class BaileysStartupService extends ChannelStartupService { if (!isJidGroup(groupJid)) return null; if (await groupMetadataCache.has(groupJid)) { + this.logger.verbose(`Cache request for group: ${groupJid}`); const meta = await groupMetadataCache.get(groupJid); if (Date.now() - meta.timestamp > 3600000) { @@ -3179,6 +3182,7 @@ export class BaileysStartupService extends ChannelStartupService { return meta.data; } + this.logger.verbose(`Cache request for group: ${groupJid} - not found`); return await this.updateGroupMetadataCache(groupJid); }