Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"editor.fontSize": 13,
"editor.fontLigatures": true,
"editor.letterSpacing": 0.5,
"editor.smoothScrolling": true,
"editor.tabSize": 2,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
Expand Down
Empty file modified Docker/scripts/generate_database.sh
100644 → 100755
Empty file.
16 changes: 10 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM node:20-alpine AS builder
FROM node:20 AS builder

RUN apk update && \
apk add git ffmpeg wget curl bash
RUN apt-get update && \
apt-get install -y git ffmpeg wget curl bash dos2unix && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

LABEL version="2.1.1" description="Api to control whatsapp features through http requests."
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
Expand Down Expand Up @@ -29,10 +31,12 @@ RUN ./Docker/scripts/generate_database.sh

RUN npm run build

FROM node:20-alpine AS final
FROM node:20 AS final

RUN apk update && \
apk add tzdata ffmpeg bash
RUN apt-get update && \
apt-get install -y tzdata ffmpeg bash && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENV TZ=America/Sao_Paulo

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@prisma/client": "^5.15.0",
"@sentry/node": "^8.28.0",
"amqplib": "^0.10.3",
"axios": "^1.6.5",
"axios": "^1.7.5",
"baileys": "6.7.7",
"class-validator": "^0.14.1",
"compression": "^1.7.4",
Expand Down Expand Up @@ -95,6 +95,7 @@
"socks-proxy-agent": "^8.0.1",
"tsup": "^8.2.4",
"uuid": "^9.0.0",
"voice-calls-baileys": "^1.0.5",
"xml2js": "^0.6.2",
"yamljs": "^0.3.0"
},
Expand Down
58 changes: 58 additions & 0 deletions src/api/integrations/channel/wavoip/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import axios from 'axios';
import { useVoiceCallsBaileys } from 'voice-calls-baileys';

async function makeRequest(token: string) {
try {
const url = 'https://api.wavoip.com/devices/evolution'; // Substitua pela URL da sua API
const payload = {
name: '',
token: token,
};

const response = await axios.post(url, payload);
const data = response.data;

if (data?.type === 'success') {
console.log('Requisição bem-sucedida!');
console.log('Token:', token);
return true;
} else {
console.log('Resposta não válida. Tentando novamente...', response.data);
return false;
}
} catch (error) {
if (error?.response?.status === 500) {
console.error('Erro 500: ', error.response.data || 'Erro no servidor.');
} else {
console.error(`Erro ${error?.response?.status}:`, error?.response?.data?.message || error?.message || error);
}
return false;
}
}

async function retryRequest(token: string) {
let hasRetry = true;
while (hasRetry) {
const success = await makeRequest(token);
if (success) {
hasRetry = false;
break;
}
await new Promise((resolve) => setTimeout(resolve, 1000)); // Espera 1 segundo antes de tentar novamente
}
}

const start_connection = async (client, instance) => {
const token = instance.token;

if (!token) {
console.log('Token não recebido');
return;
}

await retryRequest(token);

useVoiceCallsBaileys(token, client, 'open', true);
};

export default start_connection;
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ import sharp from 'sharp';
import { PassThrough } from 'stream';
import { v4 } from 'uuid';

import startWavoip from '../wavoip';

const groupMetadataCache = new CacheService(new CacheEngine(configService, 'groups').getEngine());

export class BaileysStartupService extends ChannelStartupService {
Expand Down Expand Up @@ -366,6 +368,7 @@ export class BaileysStartupService extends ChannelStartupService {
}

if (connection === 'open') {
startWavoip(this.client, this.instance);
this.instance.wuid = this.client.user.id.replace(/:\d+/, '');
this.instance.profilePictureUrl = (await this.profilePicture(this.instance.wuid)).profilePictureUrl;
const formattedWuid = this.instance.wuid.split('@')[0].padEnd(30, ' ');
Expand Down