Skip to content

Commit 55a2206

Browse files
matheusmartinsInspermatheusmartinsInsper
authored andcommitted
feat: Re-enable group metadata caching in Baileys service
- Restore group metadata caching mechanisms - Uncomment cache-related methods for group updates and participants - Implement conditional group metadata retrieval based on cache configuration
1 parent 8732225 commit 55a2206

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ export class BaileysStartupService extends ChannelStartupService {
546546
return isGroupJid || isBroadcast || isNewsletter;
547547
},
548548
syncFullHistory: this.localSettings.syncFullHistory,
549-
//cachedGroupMetadata: this.getGroupMetadataCache,
549+
cachedGroupMetadata: this.getGroupMetadataCache,
550550
userDevicesCache: this.userDevicesCache,
551551
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
552552
patchMessageBeforeSending(message) {
@@ -1267,11 +1267,11 @@ export class BaileysStartupService extends ChannelStartupService {
12671267
'groups.update': (groupMetadataUpdate: Partial<GroupMetadata>[]) => {
12681268
this.sendDataWebhook(Events.GROUPS_UPDATE, groupMetadataUpdate);
12691269

1270-
// groupMetadataUpdate.forEach((group) => {
1271-
// if (isJidGroup(group.id)) {
1272-
// this.updateGroupMetadataCache(group.id);
1273-
// }
1274-
// });
1270+
groupMetadataUpdate.forEach((group) => {
1271+
if (isJidGroup(group.id)) {
1272+
this.updateGroupMetadataCache(group.id);
1273+
}
1274+
});
12751275
},
12761276

12771277
'group-participants.update': (participantsUpdate: {
@@ -1281,7 +1281,7 @@ export class BaileysStartupService extends ChannelStartupService {
12811281
}) => {
12821282
this.sendDataWebhook(Events.GROUP_PARTICIPANTS_UPDATE, participantsUpdate);
12831283

1284-
//this.updateGroupMetadataCache(participantsUpdate.id);
1284+
this.updateGroupMetadataCache(participantsUpdate.id);
12851285
},
12861286
};
12871287

@@ -1830,10 +1830,10 @@ export class BaileysStartupService extends ChannelStartupService {
18301830
if (isJidGroup(sender)) {
18311831
let group;
18321832
try {
1833-
// const cache = this.configService.get<CacheConf>('CACHE');
1834-
// if (!cache.REDIS.ENABLED && !cache.LOCAL.ENABLED) group = await this.findGroup({ groupJid: sender }, 'inner');
1835-
// else group = await this.getGroupMetadataCache(sender);
1836-
group = await this.findGroup({ groupJid: sender }, 'inner');
1833+
const cache = this.configService.get<CacheConf>('CACHE');
1834+
if (!cache.REDIS.ENABLED && !cache.LOCAL.ENABLED) group = await this.findGroup({ groupJid: sender }, 'inner');
1835+
else group = await this.getGroupMetadataCache(sender);
1836+
// group = await this.findGroup({ groupJid: sender }, 'inner');
18371837
} catch (error) {
18381838
throw new NotFoundException('Group not found');
18391839
}

0 commit comments

Comments
 (0)