mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-20 10:16:43 -06:00
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.
This commit is contained in:
parent
053a7981d1
commit
5b47bc9ef0
@ -49,7 +49,7 @@
|
||||
"amqplib": "^0.10.3",
|
||||
"@aws-sdk/client-sqs": "^3.569.0",
|
||||
"axios": "^1.6.5",
|
||||
"@whiskeysockets/baileys": "6.7.5",
|
||||
"baileys": "github:bobslavtriev/Baileys",
|
||||
"class-validator": "^0.14.1",
|
||||
"compression": "^1.7.4",
|
||||
"cors": "^2.8.5",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { delay } from '@whiskeysockets/baileys';
|
||||
import { delay } from 'baileys';
|
||||
import { isURL } from 'class-validator';
|
||||
import EventEmitter2 from 'eventemitter2';
|
||||
import { v4 } from 'uuid';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { proto, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '@whiskeysockets/baileys';
|
||||
import { proto, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from 'baileys';
|
||||
|
||||
export class OnWhatsAppDto {
|
||||
constructor(
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { WAPresence } from '@whiskeysockets/baileys';
|
||||
import { WAPresence } from 'baileys';
|
||||
|
||||
import { ProxyDto } from './proxy.dto';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { proto, WAPresence } from '@whiskeysockets/baileys';
|
||||
import { proto, WAPresence } from 'baileys';
|
||||
|
||||
export class Quoted {
|
||||
key: proto.IMessageKey;
|
||||
|
@ -8,7 +8,7 @@ import ChatwootClient, {
|
||||
inbox,
|
||||
} from '@figuro/chatwoot-sdk';
|
||||
import { request as chatwootRequest } from '@figuro/chatwoot-sdk/dist/core/request';
|
||||
import { proto } from '@whiskeysockets/baileys';
|
||||
import { proto } from 'baileys';
|
||||
import axios from 'axios';
|
||||
import FormData from 'form-data';
|
||||
import { createReadStream, unlinkSync, writeFileSync } from 'fs';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { inbox } from '@figuro/chatwoot-sdk';
|
||||
import { proto } from '@whiskeysockets/baileys';
|
||||
import { proto } from 'baileys';
|
||||
|
||||
import { InstanceDto } from '../../../../api/dto/instance.dto';
|
||||
import { ChatwootRaw, ContactRaw, MessageRaw } from '../../../../api/models';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { BufferJSON } from '@whiskeysockets/baileys';
|
||||
import { BufferJSON } from 'baileys';
|
||||
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { ICache } from '../abstract/abstract.cache';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { WASocket } from '@whiskeysockets/baileys';
|
||||
import { WASocket } from 'baileys';
|
||||
import axios from 'axios';
|
||||
import { execSync } from 'child_process';
|
||||
import { isURL } from 'class-validator';
|
||||
|
@ -35,9 +35,9 @@ import makeWASocket, {
|
||||
WAMessageUpdate,
|
||||
WAPresence,
|
||||
WASocket,
|
||||
} from '@whiskeysockets/baileys';
|
||||
import { Label } from '@whiskeysockets/baileys/lib/Types/Label';
|
||||
import { LabelAssociation } from '@whiskeysockets/baileys/lib/Types/LabelAssociation';
|
||||
} from 'baileys';
|
||||
import { Label } from 'baileys/lib/Types/Label';
|
||||
import { LabelAssociation } from 'baileys/lib/Types/LabelAssociation';
|
||||
import axios from 'axios';
|
||||
import { exec } from 'child_process';
|
||||
import { isBase64, isURL } from 'class-validator';
|
||||
@ -618,6 +618,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
},
|
||||
userDevicesCache: this.userDevicesCache,
|
||||
transactionOpts: { maxCommitRetries: 5, delayBetweenTriesMs: 2500 },
|
||||
cachedGroupMetadata: this.getGroupMetadataCache,
|
||||
patchMessageBeforeSending(message) {
|
||||
if (
|
||||
message.deviceSentMessage?.message?.listMessage?.listType ===
|
||||
@ -1946,11 +1947,9 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
} as unknown as AnyMessageContent,
|
||||
{
|
||||
...option,
|
||||
cachedGroupMetadata:
|
||||
!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
|
||||
!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED
|
||||
? null
|
||||
: this.getGroupMetadataCache,
|
||||
useCachedGroupMetadata:
|
||||
!!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
|
||||
!!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED,
|
||||
} as unknown as MiscMessageGenerationOptions,
|
||||
);
|
||||
}
|
||||
@ -1966,11 +1965,9 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
} as unknown as AnyMessageContent,
|
||||
{
|
||||
...option,
|
||||
cachedGroupMetadata:
|
||||
!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
|
||||
!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED
|
||||
? null
|
||||
: this.getGroupMetadataCache,
|
||||
useCachedGroupMetadata:
|
||||
!!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
|
||||
!!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED,
|
||||
} as unknown as MiscMessageGenerationOptions,
|
||||
);
|
||||
}
|
||||
@ -1988,11 +1985,9 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
},
|
||||
{
|
||||
...option,
|
||||
cachedGroupMetadata:
|
||||
!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
|
||||
!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED
|
||||
? null
|
||||
: this.getGroupMetadataCache,
|
||||
useCachedGroupMetadata:
|
||||
!!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
|
||||
!!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED,
|
||||
} as unknown as MiscMessageGenerationOptions,
|
||||
);
|
||||
}
|
||||
@ -2016,11 +2011,9 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
message as unknown as AnyMessageContent,
|
||||
{
|
||||
...option,
|
||||
cachedGroupMetadata:
|
||||
!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
|
||||
!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED
|
||||
? null
|
||||
: this.getGroupMetadataCache,
|
||||
useCachedGroupMetadata:
|
||||
!!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
|
||||
!!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED,
|
||||
} as unknown as MiscMessageGenerationOptions,
|
||||
);
|
||||
})();
|
||||
@ -3354,6 +3347,10 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
}
|
||||
|
||||
public async findGroup(id: GroupJid, reply: 'inner' | 'out' = 'out') {
|
||||
if (this.localSettings.groups_ignore === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.logger.verbose('Fetching group');
|
||||
try {
|
||||
const group = await this.client.groupMetadata(id.groupJid);
|
||||
@ -3384,6 +3381,10 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
}
|
||||
|
||||
public async fetchAllGroups(getParticipants: GetParticipant) {
|
||||
if (this.localSettings.groups_ignore === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.logger.verbose('Fetching all groups');
|
||||
try {
|
||||
const fetch = Object.values(await this.client.groupFetchAllParticipating());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
import { AuthenticationState, WAConnectionState } from '@whiskeysockets/baileys';
|
||||
import { AuthenticationState, WAConnectionState } from 'baileys';
|
||||
|
||||
export enum Events {
|
||||
APPLICATION_STARTUP = 'application.startup',
|
||||
|
2
src/cache/rediscache.ts
vendored
2
src/cache/rediscache.ts
vendored
@ -1,4 +1,4 @@
|
||||
import { BufferJSON } from '@whiskeysockets/baileys';
|
||||
import { BufferJSON } from 'baileys';
|
||||
import { RedisClientType } from 'redis';
|
||||
|
||||
import { ICache } from '../api/abstract/abstract.cache';
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
initAuthCreds,
|
||||
proto,
|
||||
SignalDataTypeMap,
|
||||
} from '@whiskeysockets/baileys';
|
||||
} from 'baileys';
|
||||
|
||||
import { configService, Database } from '../config/env.config';
|
||||
import { Logger } from '../config/logger.config';
|
||||
|
@ -41,7 +41,7 @@ import {
|
||||
initAuthCreds,
|
||||
proto,
|
||||
SignalDataTypeMap,
|
||||
} from '@whiskeysockets/baileys';
|
||||
} from 'baileys';
|
||||
import { isNotEmpty } from 'class-validator';
|
||||
|
||||
import { ProviderFiles } from '../api/provider/sessions';
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
initAuthCreds,
|
||||
proto,
|
||||
SignalDataTypeMap,
|
||||
} from '@whiskeysockets/baileys';
|
||||
} from 'baileys';
|
||||
|
||||
import { CacheService } from '../api/services/cache.service';
|
||||
import { Logger } from '../config/logger.config';
|
||||
|
Loading…
Reference in New Issue
Block a user