Skip to content

Commit 5b47bc9

Browse files
committed
feat: update dependencies and improve caching logic
Updated package.json to include latest dependencies. Enhanced caching logic in cache.service.ts and rediscache.ts for better performance. Improved DTOs in chat.dto.ts, instance.dto.ts, and sendMessage.dto.ts for more robust data handling. Refined instance.controller.ts and chatwoot.service.ts to streamline API integrations. Adjusted authentication state management in use-multi-file-auth-state-db.ts, use-multi-file-auth-state-provider-files.ts, and use-multi-file-auth-state-redis-db.ts. These changes aim to optimize the system's performance and reliability.
1 parent 053a798 commit 5b47bc9

15 files changed

+38
-37
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"amqplib": "^0.10.3",
5050
"@aws-sdk/client-sqs": "^3.569.0",
5151
"axios": "^1.6.5",
52-
"@whiskeysockets/baileys": "6.7.5",
52+
"baileys": "github:bobslavtriev/Baileys",
5353
"class-validator": "^0.14.1",
5454
"compression": "^1.7.4",
5555
"cors": "^2.8.5",

src/api/controllers/instance.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { delay } from '@whiskeysockets/baileys';
1+
import { delay } from 'baileys';
22
import { isURL } from 'class-validator';
33
import EventEmitter2 from 'eventemitter2';
44
import { v4 } from 'uuid';

src/api/dto/chat.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { proto, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '@whiskeysockets/baileys';
1+
import { proto, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from 'baileys';
22

33
export class OnWhatsAppDto {
44
constructor(

src/api/dto/instance.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { WAPresence } from '@whiskeysockets/baileys';
1+
import { WAPresence } from 'baileys';
22

33
import { ProxyDto } from './proxy.dto';
44

src/api/dto/sendMessage.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { proto, WAPresence } from '@whiskeysockets/baileys';
1+
import { proto, WAPresence } from 'baileys';
22

33
export class Quoted {
44
key: proto.IMessageKey;

src/api/integrations/chatwoot/services/chatwoot.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import ChatwootClient, {
88
inbox,
99
} from '@figuro/chatwoot-sdk';
1010
import { request as chatwootRequest } from '@figuro/chatwoot-sdk/dist/core/request';
11-
import { proto } from '@whiskeysockets/baileys';
11+
import { proto } from 'baileys';
1212
import axios from 'axios';
1313
import FormData from 'form-data';
1414
import { createReadStream, unlinkSync, writeFileSync } from 'fs';

src/api/integrations/chatwoot/utils/chatwoot-import-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { inbox } from '@figuro/chatwoot-sdk';
2-
import { proto } from '@whiskeysockets/baileys';
2+
import { proto } from 'baileys';
33

44
import { InstanceDto } from '../../../../api/dto/instance.dto';
55
import { ChatwootRaw, ContactRaw, MessageRaw } from '../../../../api/models';

src/api/services/cache.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BufferJSON } from '@whiskeysockets/baileys';
1+
import { BufferJSON } from 'baileys';
22

33
import { Logger } from '../../config/logger.config';
44
import { ICache } from '../abstract/abstract.cache';

src/api/services/channel.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { WASocket } from '@whiskeysockets/baileys';
1+
import { WASocket } from 'baileys';
22
import axios from 'axios';
33
import { execSync } from 'child_process';
44
import { isURL } from 'class-validator';

src/api/services/channels/whatsapp.baileys.service.ts

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ import makeWASocket, {
3535
WAMessageUpdate,
3636
WAPresence,
3737
WASocket,
38-
} from '@whiskeysockets/baileys';
39-
import { Label } from '@whiskeysockets/baileys/lib/Types/Label';
40-
import { LabelAssociation } from '@whiskeysockets/baileys/lib/Types/LabelAssociation';
38+
} from 'baileys';
39+
import { Label } from 'baileys/lib/Types/Label';
40+
import { LabelAssociation } from 'baileys/lib/Types/LabelAssociation';
4141
import axios from 'axios';
4242
import { exec } from 'child_process';
4343
import { isBase64, isURL } from 'class-validator';
@@ -618,6 +618,7 @@ export class BaileysStartupService extends ChannelStartupService {
618618
},
619619
userDevicesCache: this.userDevicesCache,
620620
transactionOpts: { maxCommitRetries: 5, delayBetweenTriesMs: 2500 },
621+
cachedGroupMetadata: this.getGroupMetadataCache,
621622
patchMessageBeforeSending(message) {
622623
if (
623624
message.deviceSentMessage?.message?.listMessage?.listType ===
@@ -1946,11 +1947,9 @@ export class BaileysStartupService extends ChannelStartupService {
19461947
} as unknown as AnyMessageContent,
19471948
{
19481949
...option,
1949-
cachedGroupMetadata:
1950-
!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
1951-
!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED
1952-
? null
1953-
: this.getGroupMetadataCache,
1950+
useCachedGroupMetadata:
1951+
!!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
1952+
!!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED,
19541953
} as unknown as MiscMessageGenerationOptions,
19551954
);
19561955
}
@@ -1966,11 +1965,9 @@ export class BaileysStartupService extends ChannelStartupService {
19661965
} as unknown as AnyMessageContent,
19671966
{
19681967
...option,
1969-
cachedGroupMetadata:
1970-
!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
1971-
!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED
1972-
? null
1973-
: this.getGroupMetadataCache,
1968+
useCachedGroupMetadata:
1969+
!!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
1970+
!!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED,
19741971
} as unknown as MiscMessageGenerationOptions,
19751972
);
19761973
}
@@ -1988,11 +1985,9 @@ export class BaileysStartupService extends ChannelStartupService {
19881985
},
19891986
{
19901987
...option,
1991-
cachedGroupMetadata:
1992-
!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
1993-
!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED
1994-
? null
1995-
: this.getGroupMetadataCache,
1988+
useCachedGroupMetadata:
1989+
!!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
1990+
!!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED,
19961991
} as unknown as MiscMessageGenerationOptions,
19971992
);
19981993
}
@@ -2016,11 +2011,9 @@ export class BaileysStartupService extends ChannelStartupService {
20162011
message as unknown as AnyMessageContent,
20172012
{
20182013
...option,
2019-
cachedGroupMetadata:
2020-
!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
2021-
!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED
2022-
? null
2023-
: this.getGroupMetadataCache,
2014+
useCachedGroupMetadata:
2015+
!!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
2016+
!!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED,
20242017
} as unknown as MiscMessageGenerationOptions,
20252018
);
20262019
})();
@@ -3354,6 +3347,10 @@ export class BaileysStartupService extends ChannelStartupService {
33543347
}
33553348

33563349
public async findGroup(id: GroupJid, reply: 'inner' | 'out' = 'out') {
3350+
if (this.localSettings.groups_ignore === true) {
3351+
return;
3352+
}
3353+
33573354
this.logger.verbose('Fetching group');
33583355
try {
33593356
const group = await this.client.groupMetadata(id.groupJid);
@@ -3384,6 +3381,10 @@ export class BaileysStartupService extends ChannelStartupService {
33843381
}
33853382

33863383
public async fetchAllGroups(getParticipants: GetParticipant) {
3384+
if (this.localSettings.groups_ignore === true) {
3385+
return;
3386+
}
3387+
33873388
this.logger.verbose('Fetching all groups');
33883389
try {
33893390
const fetch = Object.values(await this.client.groupFetchAllParticipating());

0 commit comments

Comments
 (0)