diff --git a/package.json b/package.json index 8ee94b3e..327e17c8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/api/controllers/instance.controller.ts b/src/api/controllers/instance.controller.ts index bc3ace61..3b2ea0e4 100644 --- a/src/api/controllers/instance.controller.ts +++ b/src/api/controllers/instance.controller.ts @@ -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'; diff --git a/src/api/dto/chat.dto.ts b/src/api/dto/chat.dto.ts index 3ed55d52..7952ddc6 100644 --- a/src/api/dto/chat.dto.ts +++ b/src/api/dto/chat.dto.ts @@ -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( diff --git a/src/api/dto/instance.dto.ts b/src/api/dto/instance.dto.ts index d9a4d87a..1f2ff1c6 100644 --- a/src/api/dto/instance.dto.ts +++ b/src/api/dto/instance.dto.ts @@ -1,4 +1,4 @@ -import { WAPresence } from '@whiskeysockets/baileys'; +import { WAPresence } from 'baileys'; import { ProxyDto } from './proxy.dto'; diff --git a/src/api/dto/sendMessage.dto.ts b/src/api/dto/sendMessage.dto.ts index 7bb33074..5c197d44 100644 --- a/src/api/dto/sendMessage.dto.ts +++ b/src/api/dto/sendMessage.dto.ts @@ -1,4 +1,4 @@ -import { proto, WAPresence } from '@whiskeysockets/baileys'; +import { proto, WAPresence } from 'baileys'; export class Quoted { key: proto.IMessageKey; diff --git a/src/api/integrations/chatwoot/services/chatwoot.service.ts b/src/api/integrations/chatwoot/services/chatwoot.service.ts index 9a30dc12..a837c03e 100644 --- a/src/api/integrations/chatwoot/services/chatwoot.service.ts +++ b/src/api/integrations/chatwoot/services/chatwoot.service.ts @@ -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'; diff --git a/src/api/integrations/chatwoot/utils/chatwoot-import-helper.ts b/src/api/integrations/chatwoot/utils/chatwoot-import-helper.ts index dd0bb23a..e102aa57 100644 --- a/src/api/integrations/chatwoot/utils/chatwoot-import-helper.ts +++ b/src/api/integrations/chatwoot/utils/chatwoot-import-helper.ts @@ -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'; diff --git a/src/api/services/cache.service.ts b/src/api/services/cache.service.ts index caf3dbfa..e03b3eb5 100644 --- a/src/api/services/cache.service.ts +++ b/src/api/services/cache.service.ts @@ -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'; diff --git a/src/api/services/channel.service.ts b/src/api/services/channel.service.ts index ac4eae90..c7e96b04 100644 --- a/src/api/services/channel.service.ts +++ b/src/api/services/channel.service.ts @@ -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'; diff --git a/src/api/services/channels/whatsapp.baileys.service.ts b/src/api/services/channels/whatsapp.baileys.service.ts index 210dc72b..21167f36 100644 --- a/src/api/services/channels/whatsapp.baileys.service.ts +++ b/src/api/services/channels/whatsapp.baileys.service.ts @@ -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('CACHE').REDIS.ENABLED && - !this.configService.get('CACHE').LOCAL.ENABLED - ? null - : this.getGroupMetadataCache, + useCachedGroupMetadata: + !!this.configService.get('CACHE').REDIS.ENABLED && + !!this.configService.get('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('CACHE').REDIS.ENABLED && - !this.configService.get('CACHE').LOCAL.ENABLED - ? null - : this.getGroupMetadataCache, + useCachedGroupMetadata: + !!this.configService.get('CACHE').REDIS.ENABLED && + !!this.configService.get('CACHE').LOCAL.ENABLED, } as unknown as MiscMessageGenerationOptions, ); } @@ -1988,11 +1985,9 @@ export class BaileysStartupService extends ChannelStartupService { }, { ...option, - cachedGroupMetadata: - !this.configService.get('CACHE').REDIS.ENABLED && - !this.configService.get('CACHE').LOCAL.ENABLED - ? null - : this.getGroupMetadataCache, + useCachedGroupMetadata: + !!this.configService.get('CACHE').REDIS.ENABLED && + !!this.configService.get('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('CACHE').REDIS.ENABLED && - !this.configService.get('CACHE').LOCAL.ENABLED - ? null - : this.getGroupMetadataCache, + useCachedGroupMetadata: + !!this.configService.get('CACHE').REDIS.ENABLED && + !!this.configService.get('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()); diff --git a/src/api/types/wa.types.ts b/src/api/types/wa.types.ts index 9c33ac6f..94461964 100644 --- a/src/api/types/wa.types.ts +++ b/src/api/types/wa.types.ts @@ -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', diff --git a/src/cache/rediscache.ts b/src/cache/rediscache.ts index 6e209ef1..c4e98968 100644 --- a/src/cache/rediscache.ts +++ b/src/cache/rediscache.ts @@ -1,4 +1,4 @@ -import { BufferJSON } from '@whiskeysockets/baileys'; +import { BufferJSON } from 'baileys'; import { RedisClientType } from 'redis'; import { ICache } from '../api/abstract/abstract.cache'; diff --git a/src/utils/use-multi-file-auth-state-db.ts b/src/utils/use-multi-file-auth-state-db.ts index 995ac92a..a0bad105 100644 --- a/src/utils/use-multi-file-auth-state-db.ts +++ b/src/utils/use-multi-file-auth-state-db.ts @@ -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'; diff --git a/src/utils/use-multi-file-auth-state-provider-files.ts b/src/utils/use-multi-file-auth-state-provider-files.ts index 1051af8f..f72e6855 100644 --- a/src/utils/use-multi-file-auth-state-provider-files.ts +++ b/src/utils/use-multi-file-auth-state-provider-files.ts @@ -41,7 +41,7 @@ import { initAuthCreds, proto, SignalDataTypeMap, -} from '@whiskeysockets/baileys'; +} from 'baileys'; import { isNotEmpty } from 'class-validator'; import { ProviderFiles } from '../api/provider/sessions'; diff --git a/src/utils/use-multi-file-auth-state-redis-db.ts b/src/utils/use-multi-file-auth-state-redis-db.ts index 66bb89ea..465b96a7 100644 --- a/src/utils/use-multi-file-auth-state-redis-db.ts +++ b/src/utils/use-multi-file-auth-state-redis-db.ts @@ -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';