From 3d02fabef423ac62177135a8c8376d6a1a8389b4 Mon Sep 17 00:00:00 2001 From: Alan Mosko Date: Thu, 27 Jul 2023 10:47:26 -0300 Subject: [PATCH 1/4] Update Dockerfile --- Dockerfile | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0b3ac9506..01f24799e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,17 @@ FROM node:16.18-alpine -LABEL version="1.1.3" description="Api to control whatsapp features through http requests." +LABEL version="1.4.7" description="Api to control whatsapp features through http requests." LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes" LABEL contact="contato@agenciadgcode.com" RUN apk update && apk upgrade && \ - apk add --no-cache git + apk add --no-cache git tzdata ffmpeg wget curl WORKDIR /evolution COPY ./package.json . +ENV TZ=America/Sao_Paulo ENV DOCKER_ENV=true ENV SERVER_URL=http://localhost:8080 @@ -40,17 +41,17 @@ ENV DATABASE_ENABLED=false ENV DATABASE_CONNECTION_URI=mongodb://root:root@mongodb:27017/?authSource=admin&readPreference=primary&ssl=false&directConnection=true ENV DATABASE_CONNECTION_DB_PREFIX_NAME=evolution -ENV DATABASE_SAVE_DATA_INSTANCE=false -ENV DATABASE_SAVE_DATA_NEW_MESSAGE=false -ENV DATABASE_SAVE_MESSAGE_UPDATE=false -ENV DATABASE_SAVE_DATA_CONTACTS=false -ENV DATABASE_SAVE_DATA_CHATS=false +ENV DATABASE_SAVE_DATA_INSTANCE=true +ENV DATABASE_SAVE_DATA_NEW_MESSAGE=true +ENV DATABASE_SAVE_MESSAGE_UPDATE=true +ENV DATABASE_SAVE_DATA_CONTACTS=true +ENV DATABASE_SAVE_DATA_CHATS=true ENV REDIS_ENABLED=false ENV REDIS_URI=redis://redis:6379 ENV REDIS_PREFIX_KEY=evolution -ENV WEBHOOK_GLOBAL_URL= +ENV WEBHOOK_GLOBAL_URL= ENV WEBHOOK_GLOBAL_ENABLED=false ENV WEBHOOK_GLOBAL_WEBHOOK_BY_EVENTS=false @@ -91,18 +92,13 @@ ENV AUTHENTICATION_EXPOSE_IN_FETCH_INSTANCES=true ENV AUTHENTICATION_JWT_EXPIRIN_IN=0 ENV AUTHENTICATION_JWT_SECRET='L=0YWt]b2w[WF>#>:&E`' -ENV AUTHENTICATION_INSTANCE_MODE=server - -ENV AUTHENTICATION_INSTANCE_NAME=evolution -ENV AUTHENTICATION_INSTANCE_WEBHOOK_URL= -ENV AUTHENTICATION_INSTANCE_CHATWOOT_ACCOUNT_ID=1 -ENV AUTHENTICATION_INSTANCE_CHATWOOT_TOKEN=123456 -ENV AUTHENTICATION_INSTANCE_CHATWOOT_URL= - RUN npm install COPY . . RUN npm run build +HEALTHCHECK --interval=1m --retries=250 --start-period=2m \ + CMD curl --fail http://$SERVER_URL/ || exit 1 + CMD [ "node", "./dist/src/main.js" ] From 2614088faecc1e40d9887ce3f88b1c85c3622d0b Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Mon, 31 Jul 2023 15:25:48 -0300 Subject: [PATCH 2/4] Revert "Update Dockerfile" --- Dockerfile | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 01f24799e..0b3ac9506 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,16 @@ FROM node:16.18-alpine -LABEL version="1.4.7" description="Api to control whatsapp features through http requests." +LABEL version="1.1.3" description="Api to control whatsapp features through http requests." LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes" LABEL contact="contato@agenciadgcode.com" RUN apk update && apk upgrade && \ - apk add --no-cache git tzdata ffmpeg wget curl + apk add --no-cache git WORKDIR /evolution COPY ./package.json . -ENV TZ=America/Sao_Paulo ENV DOCKER_ENV=true ENV SERVER_URL=http://localhost:8080 @@ -41,17 +40,17 @@ ENV DATABASE_ENABLED=false ENV DATABASE_CONNECTION_URI=mongodb://root:root@mongodb:27017/?authSource=admin&readPreference=primary&ssl=false&directConnection=true ENV DATABASE_CONNECTION_DB_PREFIX_NAME=evolution -ENV DATABASE_SAVE_DATA_INSTANCE=true -ENV DATABASE_SAVE_DATA_NEW_MESSAGE=true -ENV DATABASE_SAVE_MESSAGE_UPDATE=true -ENV DATABASE_SAVE_DATA_CONTACTS=true -ENV DATABASE_SAVE_DATA_CHATS=true +ENV DATABASE_SAVE_DATA_INSTANCE=false +ENV DATABASE_SAVE_DATA_NEW_MESSAGE=false +ENV DATABASE_SAVE_MESSAGE_UPDATE=false +ENV DATABASE_SAVE_DATA_CONTACTS=false +ENV DATABASE_SAVE_DATA_CHATS=false ENV REDIS_ENABLED=false ENV REDIS_URI=redis://redis:6379 ENV REDIS_PREFIX_KEY=evolution -ENV WEBHOOK_GLOBAL_URL= +ENV WEBHOOK_GLOBAL_URL= ENV WEBHOOK_GLOBAL_ENABLED=false ENV WEBHOOK_GLOBAL_WEBHOOK_BY_EVENTS=false @@ -92,13 +91,18 @@ ENV AUTHENTICATION_EXPOSE_IN_FETCH_INSTANCES=true ENV AUTHENTICATION_JWT_EXPIRIN_IN=0 ENV AUTHENTICATION_JWT_SECRET='L=0YWt]b2w[WF>#>:&E`' +ENV AUTHENTICATION_INSTANCE_MODE=server + +ENV AUTHENTICATION_INSTANCE_NAME=evolution +ENV AUTHENTICATION_INSTANCE_WEBHOOK_URL= +ENV AUTHENTICATION_INSTANCE_CHATWOOT_ACCOUNT_ID=1 +ENV AUTHENTICATION_INSTANCE_CHATWOOT_TOKEN=123456 +ENV AUTHENTICATION_INSTANCE_CHATWOOT_URL= + RUN npm install COPY . . RUN npm run build -HEALTHCHECK --interval=1m --retries=250 --start-period=2m \ - CMD curl --fail http://$SERVER_URL/ || exit 1 - CMD [ "node", "./dist/src/main.js" ] From 6e401eecdef2ae450f9713965fe5dc382c01446c Mon Sep 17 00:00:00 2001 From: Allyson de Paula Date: Wed, 9 Aug 2023 16:56:38 -0300 Subject: [PATCH 3/4] Bugfix Internal Error 500: fetchInstances (apikey not found) --- src/whatsapp/controllers/instance.controller.ts | 3 ++- src/whatsapp/services/monitor.service.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/whatsapp/controllers/instance.controller.ts b/src/whatsapp/controllers/instance.controller.ts index 2b62af23c..900df29a6 100644 --- a/src/whatsapp/controllers/instance.controller.ts +++ b/src/whatsapp/controllers/instance.controller.ts @@ -286,12 +286,13 @@ export class InstanceController { } public async fetchInstances({ instanceName }: InstanceDto) { - this.logger.verbose('requested fetchInstances from ' + instanceName + ' instance'); if (instanceName) { + this.logger.verbose('requested fetchInstances from ' + instanceName + ' instance'); this.logger.verbose('instanceName: ' + instanceName); return this.waMonitor.instanceInfo(instanceName); } + this.logger.verbose('requested fetchInstances (all instances)'); return this.waMonitor.instanceInfo(); } diff --git a/src/whatsapp/services/monitor.service.ts b/src/whatsapp/services/monitor.service.ts index 50f671d98..9df6a0e35 100644 --- a/src/whatsapp/services/monitor.service.ts +++ b/src/whatsapp/services/monitor.service.ts @@ -115,7 +115,7 @@ export class WAMonitoringService { if (this.configService.get('AUTHENTICATION').EXPOSE_IN_FETCH_INSTANCES) { instanceData.instance['serverUrl'] = this.configService.get('SERVER').URL; - instanceData.instance['apikey'] = (await this.repository.auth.find(key)).apikey; + instanceData.instance['apikey'] = (await this.repository.auth.find(key))?.apikey; instanceData.instance['chatwoot'] = chatwoot; } @@ -134,7 +134,7 @@ export class WAMonitoringService { if (this.configService.get('AUTHENTICATION').EXPOSE_IN_FETCH_INSTANCES) { instanceData.instance['serverUrl'] = this.configService.get('SERVER').URL; - instanceData.instance['apikey'] = (await this.repository.auth.find(key)).apikey; + instanceData.instance['apikey'] = (await this.repository.auth.find(key))?.apikey; instanceData.instance['chatwoot'] = chatwoot; } From 907a0ee1354247bbaa8eff3a4b682dabd0bc6b24 Mon Sep 17 00:00:00 2001 From: Allyson de Paula Date: Sat, 12 Aug 2023 15:05:10 -0300 Subject: [PATCH 4/4] Proxy test --- package.json | 1 + src/whatsapp/services/whatsapp.service.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/package.json b/package.json index 54511a9c0..384db0fd4 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "qrcode-terminal": "^0.12.0", "redis": "^4.6.5", "sharp": "^0.30.7", + "socks-proxy-agent": "^8.0.1", "uuid": "^9.0.0" }, "devDependencies": { diff --git a/src/whatsapp/services/whatsapp.service.ts b/src/whatsapp/services/whatsapp.service.ts index 6de7d8473..8d439d45d 100644 --- a/src/whatsapp/services/whatsapp.service.ts +++ b/src/whatsapp/services/whatsapp.service.ts @@ -121,6 +121,7 @@ import { RepositoryBroker } from '../repository/repository.manager'; import { Events, MessageSubtype, TypeMediaMessage, wa } from '../types/wa.types'; import { waMonitor } from '../whatsapp.module'; import { ChatwootService } from './chatwoot.service'; +import { SocksProxyAgent } from 'socks-proxy-agent'; export class WAStartupService { constructor( @@ -874,6 +875,7 @@ export class WAStartupService { return message; }, + // agent: new SocksProxyAgent('socks5://192.168.1.4:1080'), }; this.endSession = false;