diff --git a/.gitignore b/.gitignore index 10508850..6e059b6c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ yarn-error.log* lerna-debug.log* /docker-compose-data +/docker-data # Package /yarn.lock diff --git a/Dockerfile b/Dockerfile index 28e330e8..6fedce79 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,6 +48,7 @@ ENV DATABASE_SAVE_DATA_CHATS=$DATABASE_SAVE_DATA_CHATS ENV REDIS_ENABLED=$REDIS_ENABLED ENV REDIS_URI=$REDIS_URI +ENV REDIS_PREFIX_KEY=$REDIS_PREFIX_KEY ENV WEBHOOK_GLOBAL_URL=$WEBHOOK_GLOBAL_URL ENV WEBHOOK_GLOBAL_ENABLED=$WEBHOOK_GLOBAL_ENABLED diff --git a/package.json b/package.json index 1feb80af..039c396f 100644 --- a/package.json +++ b/package.json @@ -40,10 +40,10 @@ }, "homepage": "https://github.com/EvolutionAPI/evolution-api#readme", "dependencies": { - "@whiskeysockets/baileys": "github:EvolutionAPI/Baileys", "@adiwajshing/keyed-db": "^0.2.4", "@ffmpeg-installer/ffmpeg": "^1.1.0", "@hapi/boom": "^10.0.1", + "@whiskeysockets/baileys": "github:EvolutionAPI/Baileys", "axios": "^1.3.5", "class-validator": "^0.13.2", "compression": "^1.7.4", @@ -65,6 +65,7 @@ "node-cache": "^5.1.2", "node-mime-types": "^1.1.0", "pino": "^8.11.0", + "proxy-agent": "^6.2.1", "qrcode": "^1.5.1", "qrcode-terminal": "^0.12.0", "redis": "^4.6.5", diff --git a/src/whatsapp/services/whatsapp.service.ts b/src/whatsapp/services/whatsapp.service.ts index 9f551569..692f0e33 100644 --- a/src/whatsapp/services/whatsapp.service.ts +++ b/src/whatsapp/services/whatsapp.service.ts @@ -119,6 +119,7 @@ import { useMultiFileAuthStateRedisDb } from '../../utils/use-multi-file-auth-st import sharp from 'sharp'; import { RedisCache } from '../../db/redis.client'; import { Log } from '../../config/env.config'; +import ProxyAgent from 'proxy-agent'; export class WAStartupService { constructor( @@ -1421,16 +1422,27 @@ export class WAStartupService { }; } if (status.type === 'audio') { - return { - content: { - audio: { - url: status.content, + const convert = await this.processAudio(status.content, 'status@broadcast'); + if (typeof convert === 'string') { + const audio = fs.readFileSync(convert).toString('base64'); + + const result = { + content: { + audio: Buffer.from(audio, 'base64'), + ptt: true, + mimetype: 'audio/mp4', }, - }, - option: { - statusJidList: status.statusJidList, - }, - }; + option: { + statusJidList: status.statusJidList, + }, + }; + + fs.unlinkSync(convert); + + return result; + } else { + throw new InternalServerErrorException(convert); + } } throw new BadRequestException('Type not found');