diff --git a/CHANGELOG.md b/CHANGELOG.md index a1bc86d6..383282ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # 2.3.1 (develop) +### Feature + +* Add BaileysMessageProcessor for improved message handling and integrate rxjs for asynchronous processing +* Enhance message processing with retry logic for error handling + ### Fixed * Update Baileys Version @@ -8,6 +13,9 @@ * Add unreadMessages in the response * Phone number as message ID for Evo AI * Fix upload to s3 when media message +* Simplify edited message check in BaileysStartupService +* Avoid corrupting URLs with query strings +* Removed CONFIG_SESSION_PHONE_VERSION environment variable # 2.3.0 (2025-06-17 09:19) diff --git a/Docker/swarm/evolution_api_v2.yaml b/Docker/swarm/evolution_api_v2.yaml index c4cd30d6..4055dfa3 100644 --- a/Docker/swarm/evolution_api_v2.yaml +++ b/Docker/swarm/evolution_api_v2.yaml @@ -94,7 +94,6 @@ services: - WEBHOOK_EVENTS_ERRORS_WEBHOOK= - CONFIG_SESSION_PHONE_CLIENT=Evolution API V2 - CONFIG_SESSION_PHONE_NAME=Chrome - #- CONFIG_SESSION_PHONE_VERSION=2.3000.1023204200 - QRCODE_LIMIT=30 - OPENAI_ENABLED=true - DIFY_ENABLED=true diff --git a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts index 8496a759..f9dbeed0 100644 --- a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts @@ -549,17 +549,18 @@ export class BaileysStartupService extends ChannelStartupService { this.logger.info(`Browser: ${browser}`); } - let version; - let log; + const baileysVersion = await fetchLatestWaWebVersion({}); + const version = baileysVersion.version; + const log = `Baileys version: ${version.join('.')}`; - if (session.VERSION) { - version = session.VERSION.split('.'); - log = `Baileys version env: ${version}`; - } else { - const baileysVersion = await fetchLatestWaWebVersion({}); - version = baileysVersion.version; - log = `Baileys version: ${version}`; - } + // if (session.VERSION) { + // version = session.VERSION.split('.'); + // log = `Baileys version env: ${version}`; + // } else { + // const baileysVersion = await fetchLatestWaWebVersion({}); + // version = baileysVersion.version; + // log = `Baileys version: ${version}`; + // } this.logger.info(log); @@ -1059,6 +1060,8 @@ export class BaileysStartupService extends ChannelStartupService { 'failed to decrypt message', 'SessionError', 'Invalid PreKey ID', + 'No session record', + 'No session found to decrypt message', ].some((err) => param?.includes?.(err)), ) ) { @@ -2559,7 +2562,9 @@ export class BaileysStartupService extends ChannelStartupService { imageBuffer = Buffer.from(base64Data, 'base64'); } else { const timestamp = new Date().getTime(); - const url = `${image}?timestamp=${timestamp}`; + const parsedURL = new URL(image); + parsedURL.searchParams.set('timestamp', timestamp.toString()); + const url = parsedURL.toString(); let config: any = { responseType: 'arraybuffer' }; @@ -2780,7 +2785,9 @@ export class BaileysStartupService extends ChannelStartupService { if (isURL(audio)) { const timestamp = new Date().getTime(); - const url = `${audio}?timestamp=${timestamp}`; + const parsedURL = new URL(audio); + parsedURL.searchParams.set('timestamp', timestamp.toString()); + const url = parsedURL.toString(); const config: any = { responseType: 'stream' }; @@ -3709,7 +3716,9 @@ export class BaileysStartupService extends ChannelStartupService { let pic: WAMediaUpload; if (isURL(picture)) { const timestamp = new Date().getTime(); - const url = `${picture}?timestamp=${timestamp}`; + const parsedURL = new URL(picture); + parsedURL.searchParams.set('timestamp', timestamp.toString()); + const url = parsedURL.toString(); let config: any = { responseType: 'arraybuffer' }; @@ -4001,7 +4010,9 @@ export class BaileysStartupService extends ChannelStartupService { let pic: WAMediaUpload; if (isURL(picture.image)) { const timestamp = new Date().getTime(); - const url = `${picture.image}?timestamp=${timestamp}`; + const parsedURL = new URL(picture.image); + parsedURL.searchParams.set('timestamp', timestamp.toString()); + const url = parsedURL.toString(); let config: any = { responseType: 'arraybuffer' }; diff --git a/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts b/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts index 5561ee6f..badaba13 100644 --- a/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts +++ b/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts @@ -681,7 +681,7 @@ export class ChatwootService { instance, body.key.participant.split('@')[0], filterInbox.id, - isGroup, + false, body.pushName, picture_url.profilePictureUrl || null, body.key.participant, diff --git a/src/api/routes/index.router.ts b/src/api/routes/index.router.ts index fd2372fa..48954ea0 100644 --- a/src/api/routes/index.router.ts +++ b/src/api/routes/index.router.ts @@ -69,8 +69,7 @@ router clientName: process.env.DATABASE_CONNECTION_CLIENT_NAME, manager: !serverConfig.DISABLE_MANAGER ? `${req.protocol}://${req.get('host')}/manager` : undefined, documentation: `https://doc.evolution-api.com`, - whatsappWebVersion: - process.env.CONFIG_SESSION_PHONE_VERSION || (await fetchLatestWaWebVersion({})).version.join('.'), + whatsappWebVersion: (await fetchLatestWaWebVersion({})).version.join('.'), }); }) .post('/verify-creds', authGuard['apikey'], async (req, res) => { diff --git a/src/config/env.config.ts b/src/config/env.config.ts index 8c253163..c59acd38 100644 --- a/src/config/env.config.ts +++ b/src/config/env.config.ts @@ -249,7 +249,7 @@ export type Webhook = { }; }; export type Pusher = { ENABLED: boolean; GLOBAL?: GlobalPusher; EVENTS: EventsPusher }; -export type ConfigSessionPhone = { CLIENT: string; NAME: string; VERSION: string }; +export type ConfigSessionPhone = { CLIENT: string; NAME: string }; export type QrCode = { LIMIT: number; COLOR: string }; export type Typebot = { ENABLED: boolean; API_VERSION: string; SEND_MEDIA_BASE64: boolean }; export type Chatwoot = { @@ -590,7 +590,6 @@ export class ConfigService { CONFIG_SESSION_PHONE: { CLIENT: process.env?.CONFIG_SESSION_PHONE_CLIENT || 'Evolution API', NAME: process.env?.CONFIG_SESSION_PHONE_NAME || 'Chrome', - VERSION: process.env?.CONFIG_SESSION_PHONE_VERSION || null, }, QRCODE: { LIMIT: Number.parseInt(process.env.QRCODE_LIMIT) || 30,