Skip to content

Commit 7f10a0e

Browse files
committed
Merge branch 'release/2.2.1'
2 parents 1665654 + a1085b4 commit 7f10a0e

File tree

65 files changed

+14358
-522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+14358
-522
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ DEL_INSTANCE=false
2626

2727
# Provider: postgresql | mysql
2828
DATABASE_PROVIDER=postgresql
29-
DATABASE_CONNECTION_URI='postgresql://user:pass@localhost:5432/evolution?schema=public'
29+
DATABASE_CONNECTION_URI='postgresql://user:pass@postgres:5432/evolution?schema=public'
3030
# Client name for the database connection
3131
# It is used to separate an API installation from another that uses the same database.
3232
DATABASE_CONNECTION_CLIENT_NAME=evolution_exchange

.eslintrc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
module.exports = {
22
parser: '@typescript-eslint/parser',
33
parserOptions: {
4-
sourceType: 'CommonJS',
4+
project: 'tsconfig.json',
5+
tsconfigRootDir: __dirname,
6+
sourceType: 'module',
7+
warnOnUnsupportedTypeScriptVersion: false,
8+
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
59
},
610
plugins: ['@typescript-eslint', 'simple-import-sort', 'import'],
711
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check Code Quality
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
check-lint-and-build:
7+
runs-on: ubuntu-latest
8+
timeout-minutes: 10
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Install Node
14+
uses: actions/setup-node@v1
15+
with:
16+
node-version: 20.x
17+
18+
- name: Install packages
19+
run: npm install
20+
21+
- name: Check linting
22+
run: npm run lint:check
23+
24+
- name: Check build
25+
run: npm run db:generate
26+
27+
- name: Check build
28+
run: npm run build

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ lerna-debug.log*
2121
# Package
2222
/yarn.lock
2323
/pnpm-lock.yaml
24-
/package-lock.json
2524

2625
# IDEs
2726
.vscode/*

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
# 2.2.0 (develop)
1+
# 2.2.1 (2025-01-22 14:37)
2+
3+
### Features
4+
5+
* Retry system for send webhooks
6+
* Message filtering to support timestamp range queries
7+
* Chats filtering to support timestamp range queries
8+
9+
### Fixed
10+
11+
* Correction of webhook global
12+
* Fixed send audio with whatsapp cloud api
13+
* Refactor on fetch chats
14+
* Refactor on Evolution Channel
15+
16+
# 2.2.0 (2024-10-18 10:00)
217

318
### Features
419

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
FROM node:20-alpine AS builder
22

33
RUN apk update && \
4-
apk add git ffmpeg wget curl bash
4+
apk add git ffmpeg wget curl bash openssl
55

6-
LABEL version="2.2.0" description="Api to control whatsapp features through http requests."
6+
LABEL version="2.2.1" description="Api to control whatsapp features through http requests."
77
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
88
LABEL contact="[email protected]"
99

1010
WORKDIR /evolution
1111

1212
COPY ./package.json ./tsconfig.json ./
1313

14-
RUN npm install -f
14+
RUN npm install
1515

1616
COPY ./src ./src
1717
COPY ./public ./public
@@ -32,7 +32,7 @@ RUN npm run build
3232
FROM node:20-alpine AS final
3333

3434
RUN apk update && \
35-
apk add tzdata ffmpeg bash
35+
apk add tzdata ffmpeg bash openssl
3636

3737
ENV TZ=America/Sao_Paulo
3838

docker-compose.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ services:
3434
image: postgres:15
3535
networks:
3636
- evolution-net
37-
command: ["postgres", "-c", "max_connections=1000"]
37+
command: ["postgres", "-c", "max_connections=1000", "-c", "listen_addresses=*"]
3838
restart: always
3939
ports:
4040
- 5432:5432
4141
environment:
42-
- POSTGRES_PASSWORD=PASSWORD
42+
- POSTGRES_USER=user
43+
- POSTGRES_PASSWORD=pass
44+
- POSTGRES_DB=evolution
45+
- POSTGRES_HOST_AUTH_METHOD=trust
4346
volumes:
4447
- postgres_data:/var/lib/postgresql/data
4548
expose:

local_install.sh

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
#!/bin/bash
2+
3+
# Definir cores para melhor legibilidade
4+
RED='\033[0;31m'
5+
GREEN='\033[0;32m'
6+
YELLOW='\033[1;33m'
7+
NC='\033[0m' # No Color
8+
9+
# Função para log
10+
log() {
11+
echo -e "${GREEN}[INFO]${NC} $1"
12+
}
13+
log_error() {
14+
echo -e "${RED}[ERROR]${NC} $1"
15+
}
16+
log_warning() {
17+
echo -e "${YELLOW}[WARNING]${NC} $1"
18+
}
19+
20+
# Verificar se está rodando como root
21+
if [ "$(id -u)" = "0" ]; then
22+
log_error "Este script não deve ser executado como root"
23+
exit 1
24+
fi
25+
26+
# Verificar sistema operacional
27+
OS="$(uname -s)"
28+
case "${OS}" in
29+
Linux*)
30+
if [ ! -x "$(command -v curl)" ]; then
31+
log_warning "Curl não está instalado. Tentando instalar..."
32+
if [ -x "$(command -v apt-get)" ]; then
33+
sudo apt-get update && sudo apt-get install -y curl
34+
elif [ -x "$(command -v yum)" ]; then
35+
sudo yum install -y curl
36+
else
37+
log_error "Não foi possível instalar curl automaticamente. Por favor, instale manualmente."
38+
exit 1
39+
fi
40+
fi
41+
;;
42+
Darwin*)
43+
if [ ! -x "$(command -v curl)" ]; then
44+
log_error "Curl não está instalado. Por favor, instale o Xcode Command Line Tools."
45+
exit 1
46+
fi
47+
;;
48+
*)
49+
log_error "Sistema operacional não suportado: ${OS}"
50+
exit 1
51+
;;
52+
esac
53+
54+
# Verificar conexão com a internet antes de prosseguir
55+
if ! ping -c 1 8.8.8.8 &> /dev/null; then
56+
log_error "Sem conexão com a internet. Por favor, verifique sua conexão."
57+
exit 1
58+
fi
59+
60+
# Adicionar verificação de espaço em disco
61+
REQUIRED_SPACE=1000000 # 1GB em KB
62+
AVAILABLE_SPACE=$(df -k . | awk 'NR==2 {print $4}')
63+
if [ $AVAILABLE_SPACE -lt $REQUIRED_SPACE ]; then
64+
log_error "Espaço em disco insuficiente. Necessário pelo menos 1GB livre."
65+
exit 1
66+
fi
67+
68+
# Adicionar tratamento de erro para comandos npm
69+
npm_install_with_retry() {
70+
local max_attempts=3
71+
local attempt=1
72+
73+
while [ $attempt -le $max_attempts ]; do
74+
log "Tentativa $attempt de $max_attempts para npm install"
75+
if npm install; then
76+
return 0
77+
fi
78+
attempt=$((attempt + 1))
79+
[ $attempt -le $max_attempts ] && log_warning "Falha na instalação. Tentando novamente em 5 segundos..." && sleep 5
80+
done
81+
82+
log_error "Falha ao executar npm install após $max_attempts tentativas"
83+
return 1
84+
}
85+
86+
# Adicionar timeout para comandos
87+
execute_with_timeout() {
88+
timeout 300 $@ || log_error "Comando excedeu o tempo limite de 5 minutos: $@"
89+
}
90+
91+
# Verificar se o NVM já está instalado
92+
if [ -d "$HOME/.nvm" ]; then
93+
log "NVM já está instalado."
94+
else
95+
log "Instalando NVM..."
96+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
97+
fi
98+
99+
# Carregar o NVM no ambiente atual
100+
export NVM_DIR="$HOME/.nvm"
101+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
102+
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
103+
104+
# Verificar se a versão do Node.js já está instalada
105+
if command -v node >/dev/null 2>&1 && [ "$(node -v)" = "v20.10.0" ]; then
106+
log "Node.js v20.10.0 já está instalado."
107+
else
108+
log "Instalando Node.js v20.10.0..."
109+
nvm install v20.10.0
110+
fi
111+
112+
nvm use v20.10.0
113+
114+
# Verificar as versões instaladas
115+
log "Verificando as versões instaladas:"
116+
log "Node.js: $(node -v)"
117+
log "npm: $(npm -v)"
118+
119+
# Instala dependências do projeto
120+
log "Instalando dependências do projeto..."
121+
rm -rf node_modules
122+
npm install
123+
124+
# Deploy do banco de dados
125+
log "Deploy do banco de dados..."
126+
npm run db:generate
127+
npm run db:deploy
128+
129+
# Iniciar o projeto
130+
log "Iniciando o projeto..."
131+
if [ "$1" = "-dev" ]; then
132+
npm run dev:server
133+
else
134+
npm run build
135+
npm run start:prod
136+
fi
137+
138+
log "Instalação concluída com sucesso!"
139+
140+
# Criar arquivo de log
141+
LOGFILE="./installation_log_$(date +%Y%m%d_%H%M%S).log"
142+
exec 1> >(tee -a "$LOGFILE")
143+
exec 2>&1
144+
145+
# Adicionar trap para limpeza em caso de interrupção
146+
cleanup() {
147+
log "Limpando recursos temporários..."
148+
# Adicione comandos de limpeza aqui
149+
}
150+
trap cleanup EXIT

0 commit comments

Comments
 (0)