Skip to content

Commit 24712c4

Browse files
committed
feat: Route to send status broadcast
1 parent 4bf4b4a commit 24712c4

4 files changed

Lines changed: 25 additions & 10 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ yarn-error.log*
1212
lerna-debug.log*
1313

1414
/docker-compose-data
15+
/docker-data
1516

1617
# Package
1718
/yarn.lock

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ ENV DATABASE_SAVE_DATA_CHATS=$DATABASE_SAVE_DATA_CHATS
4848

4949
ENV REDIS_ENABLED=$REDIS_ENABLED
5050
ENV REDIS_URI=$REDIS_URI
51+
ENV REDIS_PREFIX_KEY=$REDIS_PREFIX_KEY
5152

5253
ENV WEBHOOK_GLOBAL_URL=$WEBHOOK_GLOBAL_URL
5354
ENV WEBHOOK_GLOBAL_ENABLED=$WEBHOOK_GLOBAL_ENABLED

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
},
4141
"homepage": "https://github.com/EvolutionAPI/evolution-api#readme",
4242
"dependencies": {
43-
"@whiskeysockets/baileys": "github:EvolutionAPI/Baileys",
4443
"@adiwajshing/keyed-db": "^0.2.4",
4544
"@ffmpeg-installer/ffmpeg": "^1.1.0",
4645
"@hapi/boom": "^10.0.1",
46+
"@whiskeysockets/baileys": "github:EvolutionAPI/Baileys",
4747
"axios": "^1.3.5",
4848
"class-validator": "^0.13.2",
4949
"compression": "^1.7.4",
@@ -65,6 +65,7 @@
6565
"node-cache": "^5.1.2",
6666
"node-mime-types": "^1.1.0",
6767
"pino": "^8.11.0",
68+
"proxy-agent": "^6.2.1",
6869
"qrcode": "^1.5.1",
6970
"qrcode-terminal": "^0.12.0",
7071
"redis": "^4.6.5",

src/whatsapp/services/whatsapp.service.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ import { useMultiFileAuthStateRedisDb } from '../../utils/use-multi-file-auth-st
119119
import sharp from 'sharp';
120120
import { RedisCache } from '../../db/redis.client';
121121
import { Log } from '../../config/env.config';
122+
import ProxyAgent from 'proxy-agent';
122123

123124
export class WAStartupService {
124125
constructor(
@@ -1421,16 +1422,27 @@ export class WAStartupService {
14211422
};
14221423
}
14231424
if (status.type === 'audio') {
1424-
return {
1425-
content: {
1426-
audio: {
1427-
url: status.content,
1425+
const convert = await this.processAudio(status.content, 'status@broadcast');
1426+
if (typeof convert === 'string') {
1427+
const audio = fs.readFileSync(convert).toString('base64');
1428+
1429+
const result = {
1430+
content: {
1431+
audio: Buffer.from(audio, 'base64'),
1432+
ptt: true,
1433+
mimetype: 'audio/mp4',
14281434
},
1429-
},
1430-
option: {
1431-
statusJidList: status.statusJidList,
1432-
},
1433-
};
1435+
option: {
1436+
statusJidList: status.statusJidList,
1437+
},
1438+
};
1439+
1440+
fs.unlinkSync(convert);
1441+
1442+
return result;
1443+
} else {
1444+
throw new InternalServerErrorException(convert);
1445+
}
14341446
}
14351447

14361448
throw new BadRequestException('Type not found');

0 commit comments

Comments
 (0)