Skip to content

Commit 3c2ea5c

Browse files
committed
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 4a5d7a9 commit 3c2ea5c

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

+11-11
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ export class BaileysStartupService extends ChannelStartupService {
668668
shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => {
669669
return this.historySyncNotification(msg);
670670
},
671-
// cachedGroupMetadata: this.getGroupMetadataCache,
671+
cachedGroupMetadata: this.getGroupMetadataCache,
672672
userDevicesCache: this.userDevicesCache,
673673
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
674674
patchMessageBeforeSending(message) {
@@ -1562,11 +1562,11 @@ export class BaileysStartupService extends ChannelStartupService {
15621562
'groups.update': (groupMetadataUpdate: Partial<GroupMetadata>[]) => {
15631563
this.sendDataWebhook(Events.GROUPS_UPDATE, groupMetadataUpdate);
15641564

1565-
// groupMetadataUpdate.forEach((group) => {
1566-
// if (isJidGroup(group.id)) {
1567-
// this.updateGroupMetadataCache(group.id);
1568-
// }
1569-
// });
1565+
groupMetadataUpdate.forEach((group) => {
1566+
if (isJidGroup(group.id)) {
1567+
this.updateGroupMetadataCache(group.id);
1568+
}
1569+
});
15701570
},
15711571

15721572
'group-participants.update': (participantsUpdate: {
@@ -1576,7 +1576,7 @@ export class BaileysStartupService extends ChannelStartupService {
15761576
}) => {
15771577
this.sendDataWebhook(Events.GROUP_PARTICIPANTS_UPDATE, participantsUpdate);
15781578

1579-
// this.updateGroupMetadataCache(participantsUpdate.id);
1579+
this.updateGroupMetadataCache(participantsUpdate.id);
15801580
},
15811581
};
15821582

@@ -2160,10 +2160,10 @@ export class BaileysStartupService extends ChannelStartupService {
21602160
if (isJidGroup(sender)) {
21612161
let group;
21622162
try {
2163-
// const cache = this.configService.get<CacheConf>('CACHE');
2164-
// if (!cache.REDIS.ENABLED && !cache.LOCAL.ENABLED) group = await this.findGroup({ groupJid: sender }, 'inner');
2165-
// else group = await this.getGroupMetadataCache(sender);
2166-
group = await this.findGroup({ groupJid: sender }, 'inner');
2163+
const cache = this.configService.get<CacheConf>('CACHE');
2164+
if (!cache.REDIS.ENABLED && !cache.LOCAL.ENABLED) group = await this.findGroup({ groupJid: sender }, 'inner');
2165+
else group = await this.getGroupMetadataCache(sender);
2166+
// group = await this.findGroup({ groupJid: sender }, 'inner');
21672167
} catch (error) {
21682168
throw new NotFoundException('Group not found');
21692169
}

0 commit comments

Comments
 (0)