diff --git a/CHANGELOG.md b/CHANGELOG.md index a55f61d2..0c28267f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# 1.8.0 (develop) +# 1.7.4 (develop) ### Fixed * Adjusts in proxy on fetchAgent @@ -6,6 +6,7 @@ * Log when init redis cache service * Recovering messages lost with redis cache * Chatwoot inbox name +* Update Baileys version # 1.7.3 (2024-04-18 12:07) diff --git a/package.json b/package.json index f584674c..f0b252a7 100644 --- a/package.json +++ b/package.json @@ -46,10 +46,10 @@ "@figuro/chatwoot-sdk": "^1.1.16", "@hapi/boom": "^10.0.1", "@sentry/node": "^7.59.2", - "@whiskeysockets/baileys": "github:WhiskeySockets/Baileys#fix/missing-messages", "amqplib": "^0.10.3", "aws-sdk": "^2.1499.0", "axios": "^1.6.5", + "baileys": "^6.7.0", "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 8adf2d57..648e549f 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'; @@ -15,12 +15,12 @@ import { WebsocketService } from '../integrations/websocket/services/websocket.s import { RepositoryBroker } from '../repository/repository.manager'; import { AuthService, OldToken } from '../services/auth.service'; import { CacheService } from '../services/cache.service'; +import { BaileysStartupService } from '../services/channels/whatsapp.baileys.service'; +import { BusinessStartupService } from '../services/channels/whatsapp.business.service'; import { IntegrationService } from '../services/integration.service'; import { WAMonitoringService } from '../services/monitor.service'; import { SettingsService } from '../services/settings.service'; import { WebhookService } from '../services/webhook.service'; -import { BaileysStartupService } from '../services/whatsapp/whatsapp.baileys.service'; -import { BusinessStartupService } from '../services/whatsapp/whatsapp.business.service'; import { Events, Integration, wa } from '../types/wa.types'; import { ProxyController } from './proxy.controller'; diff --git a/src/api/dto/chat.dto.ts b/src/api/dto/chat.dto.ts index 24f04847..0178de2a 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 59c00a7d..f3329e3e 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 e52a03d6..cf122fb1 100644 --- a/src/api/integrations/chatwoot/services/chatwoot.service.ts +++ b/src/api/integrations/chatwoot/services/chatwoot.service.ts @@ -8,8 +8,8 @@ import ChatwootClient, { inbox, } from '@figuro/chatwoot-sdk'; import { request as chatwootRequest } from '@figuro/chatwoot-sdk/dist/core/request'; -import { proto } from '@whiskeysockets/baileys'; import axios from 'axios'; +import { proto } from 'baileys'; import FormData from 'form-data'; import { createReadStream, unlinkSync, writeFileSync } from 'fs'; import Jimp from 'jimp'; 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/whatsapp.service.ts b/src/api/services/channel.service.ts similarity index 97% rename from src/api/services/whatsapp.service.ts rename to src/api/services/channel.service.ts index 097b90d0..a6fef45b 100644 --- a/src/api/services/whatsapp.service.ts +++ b/src/api/services/channel.service.ts @@ -1,5 +1,5 @@ -import { WASocket } from '@whiskeysockets/baileys'; import axios from 'axios'; +import { WASocket } from 'baileys'; import { execSync } from 'child_process'; import { isURL } from 'class-validator'; import EventEmitter2 from 'eventemitter2'; @@ -38,17 +38,17 @@ import { waMonitor } from '../server.module'; import { Events, wa } from '../types/wa.types'; import { CacheService } from './cache.service'; -export class WAStartupService { +export class ChannelStartupService { constructor( public readonly configService: ConfigService, public readonly eventEmitter: EventEmitter2, public readonly repository: RepositoryBroker, public readonly chatwootCache: CacheService, ) { - this.logger.verbose('WAStartupService initialized'); + this.logger.verbose('ChannelStartupService initialized'); } - public readonly logger = new Logger(WAStartupService.name); + public readonly logger = new Logger(ChannelStartupService.name); public client: WASocket; public readonly instance: wa.Instance = {}; @@ -742,7 +742,7 @@ export class WAStartupService { if (this.configService.get('LOG').LEVEL.includes('WEBHOOKS')) { const logData = { - local: WAStartupService.name + '.sendData-RabbitMQ', + local: ChannelStartupService.name + '.sendData-RabbitMQ', event, instance: this.instance.name, data, @@ -798,7 +798,7 @@ export class WAStartupService { sqs.sendMessage(params, (err, data) => { if (err) { this.logger.error({ - local: WAStartupService.name + '.sendData-SQS', + local: ChannelStartupService.name + '.sendData-SQS', message: err?.message, hostName: err?.hostname, code: err?.code, @@ -810,7 +810,7 @@ export class WAStartupService { } else { if (this.configService.get('LOG').LEVEL.includes('WEBHOOKS')) { const logData = { - local: WAStartupService.name + '.sendData-SQS', + local: ChannelStartupService.name + '.sendData-SQS', event, instance: this.instance.name, data, @@ -854,7 +854,7 @@ export class WAStartupService { if (this.configService.get('LOG').LEVEL.includes('WEBHOOKS')) { const logData = { - local: WAStartupService.name + '.sendData-WebsocketGlobal', + local: ChannelStartupService.name + '.sendData-WebsocketGlobal', event, instance: this.instance.name, data, @@ -884,7 +884,7 @@ export class WAStartupService { if (this.configService.get('LOG').LEVEL.includes('WEBHOOKS')) { const logData = { - local: WAStartupService.name + '.sendData-Websocket', + local: ChannelStartupService.name + '.sendData-Websocket', event, instance: this.instance.name, data, @@ -918,7 +918,7 @@ export class WAStartupService { if (this.configService.get('LOG').LEVEL.includes('WEBHOOKS')) { const logData = { - local: WAStartupService.name + '.sendDataWebhook-local', + local: ChannelStartupService.name + '.sendDataWebhook-local', url: baseURL, event, instance: this.instance.name, @@ -958,7 +958,7 @@ export class WAStartupService { } } catch (error) { this.logger.error({ - local: WAStartupService.name + '.sendDataWebhook-local', + local: ChannelStartupService.name + '.sendDataWebhook-local', message: error?.message, hostName: error?.hostname, syscall: error?.syscall, @@ -990,7 +990,7 @@ export class WAStartupService { if (this.configService.get('LOG').LEVEL.includes('WEBHOOKS')) { const logData = { - local: WAStartupService.name + '.sendDataWebhook-global', + local: ChannelStartupService.name + '.sendDataWebhook-global', url: globalURL, event, instance: this.instance.name, @@ -1029,7 +1029,7 @@ export class WAStartupService { } } catch (error) { this.logger.error({ - local: WAStartupService.name + '.sendDataWebhook-global', + local: ChannelStartupService.name + '.sendDataWebhook-global', message: error?.message, hostName: error?.hostname, syscall: error?.syscall, diff --git a/src/api/services/whatsapp/whatsapp.baileys.service.ts b/src/api/services/channels/whatsapp.baileys.service.ts similarity index 99% rename from src/api/services/whatsapp/whatsapp.baileys.service.ts rename to src/api/services/channels/whatsapp.baileys.service.ts index 9821d9ae..b1f961a0 100644 --- a/src/api/services/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/services/channels/whatsapp.baileys.service.ts @@ -1,5 +1,6 @@ import ffmpegPath from '@ffmpeg-installer/ffmpeg'; import { Boom } from '@hapi/boom'; +import axios from 'axios'; import makeWASocket, { AnyMessageContent, BufferedEventData, @@ -35,10 +36,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'; -import axios from 'axios'; +} from 'baileys'; +import { Label } from 'baileys/lib/Types/Label'; +import { LabelAssociation } from 'baileys/lib/Types/LabelAssociation'; import { exec } from 'child_process'; import { arrayUnique, isBase64, isURL } from 'class-validator'; import EventEmitter2 from 'eventemitter2'; @@ -118,9 +118,9 @@ import { RepositoryBroker } from '../../repository/repository.manager'; import { waMonitor } from '../../server.module'; import { Events, MessageSubtype, TypeMediaMessage, wa } from '../../types/wa.types'; import { CacheService } from './../cache.service'; -import { WAStartupService } from './../whatsapp.service'; +import { ChannelStartupService } from './../channel.service'; -export class BaileysStartupService extends WAStartupService { +export class BaileysStartupService extends ChannelStartupService { constructor( public readonly configService: ConfigService, public readonly eventEmitter: EventEmitter2, diff --git a/src/api/services/whatsapp/whatsapp.business.service.ts b/src/api/services/channels/whatsapp.business.service.ts similarity index 99% rename from src/api/services/whatsapp/whatsapp.business.service.ts rename to src/api/services/channels/whatsapp.business.service.ts index 1ed2ddcd..d55f72e8 100644 --- a/src/api/services/whatsapp/whatsapp.business.service.ts +++ b/src/api/services/channels/whatsapp.business.service.ts @@ -26,9 +26,9 @@ import { ContactRaw, MessageRaw, MessageUpdateRaw, SettingsRaw } from '../../mod import { RepositoryBroker } from '../../repository/repository.manager'; import { Events, wa } from '../../types/wa.types'; import { CacheService } from './../cache.service'; -import { WAStartupService } from './../whatsapp.service'; +import { ChannelStartupService } from './../channel.service'; -export class BusinessStartupService extends WAStartupService { +export class BusinessStartupService extends ChannelStartupService { constructor( public readonly configService: ConfigService, public readonly eventEmitter: EventEmitter2, diff --git a/src/api/services/monitor.service.ts b/src/api/services/monitor.service.ts index df6b333a..afeffa95 100644 --- a/src/api/services/monitor.service.ts +++ b/src/api/services/monitor.service.ts @@ -25,8 +25,8 @@ import { import { RepositoryBroker } from '../repository/repository.manager'; import { Integration } from '../types/wa.types'; import { CacheService } from './cache.service'; -import { BaileysStartupService } from './whatsapp/whatsapp.baileys.service'; -import { BusinessStartupService } from './whatsapp/whatsapp.business.service'; +import { BaileysStartupService } from './channels/whatsapp.baileys.service'; +import { BusinessStartupService } from './channels/whatsapp.business.service'; export class WAMonitoringService { constructor( diff --git a/src/api/types/wa.types.ts b/src/api/types/wa.types.ts index 066691e4..0549f05f 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..f20db84f 100644 --- a/src/utils/use-multi-file-auth-state-db.ts +++ b/src/utils/use-multi-file-auth-state-db.ts @@ -1,11 +1,4 @@ -import { - AuthenticationCreds, - AuthenticationState, - BufferJSON, - initAuthCreds, - proto, - SignalDataTypeMap, -} from '@whiskeysockets/baileys'; +import { AuthenticationCreds, AuthenticationState, BufferJSON, initAuthCreds, proto, SignalDataTypeMap } 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-redis-db.ts b/src/utils/use-multi-file-auth-state-redis-db.ts index 66bb89ea..d077b894 100644 --- a/src/utils/use-multi-file-auth-state-redis-db.ts +++ b/src/utils/use-multi-file-auth-state-redis-db.ts @@ -1,10 +1,4 @@ -import { - AuthenticationCreds, - AuthenticationState, - initAuthCreds, - proto, - SignalDataTypeMap, -} from '@whiskeysockets/baileys'; +import { AuthenticationCreds, AuthenticationState, initAuthCreds, proto, SignalDataTypeMap } from 'baileys'; import { CacheService } from '../api/services/cache.service'; import { Logger } from '../config/logger.config';