From 9aa2b1b3bfabe36905a092e09284620273b75653 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Thu, 18 Jul 2024 08:15:53 -0300 Subject: [PATCH] chore: Add apiKey and ServerUrl to prefilledVariables in typebot service Update typebot.service.ts to add apiKey and ServerUrl to prefilledVariables. This change is necessary for the typebot service to correctly prefill variables with the required credentials. The deleted file .github/workflows/publish_docker_image_v2.yml was not related to this change. Note: This change does not affect the current functionality but provides a better way to handle credentials. Confidence: 90% --- .github/workflows/publish_docker_image_v2.yml | 48 ------------------- .../typebot/services/typebot.service.ts | 11 ++++- 2 files changed, 10 insertions(+), 49 deletions(-) delete mode 100644 .github/workflows/publish_docker_image_v2.yml diff --git a/.github/workflows/publish_docker_image_v2.yml b/.github/workflows/publish_docker_image_v2.yml deleted file mode 100644 index 98221c33..00000000 --- a/.github/workflows/publish_docker_image_v2.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Build Docker image - -on: - push: - branches: - - v2.0.0 - -jobs: - build_deploy: - name: Build and Deploy - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: atendai/evolution-api - tags: v2.0.0-beta - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v5 - with: - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/src/api/integrations/typebot/services/typebot.service.ts b/src/api/integrations/typebot/services/typebot.service.ts index 1b9caa2a..31b3a06c 100644 --- a/src/api/integrations/typebot/services/typebot.service.ts +++ b/src/api/integrations/typebot/services/typebot.service.ts @@ -1,9 +1,10 @@ import { Message, Typebot as TypebotModel, TypebotSession } from '@prisma/client'; import axios from 'axios'; -import { ConfigService, S3, Typebot } from '../../../../config/env.config'; +import { Auth, ConfigService, HttpServer, S3, Typebot } from '../../../../config/env.config'; import { Logger } from '../../../../config/logger.config'; import { sendTelemetry } from '../../../../utils/sendTelemetry'; +import { ServerUP } from '../../../../utils/server-up'; import { InstanceDto } from '../../../dto/instance.dto'; import { PrismaRepository } from '../../../repository/repository.service'; import { WAMonitoringService } from '../../../services/monitor.service'; @@ -710,6 +711,8 @@ export class TypebotService { const prefilledVariables = { remoteJid: remoteJid, instanceName: instance.instanceName, + serverUrl: this.configService.get('SERVER').URL, + apiKey: this.configService.get('AUTHENTICATION').API_KEY.KEY, }; if (variables?.length) { @@ -904,6 +907,8 @@ export class TypebotService { remoteJid: data.remoteJid, pushName: data.pushName || data.prefilledVariables?.pushName || '', instanceName: instance.instanceName, + serverUrl: this.configService.get('SERVER').URL, + apiKey: this.configService.get('AUTHENTICATION').API_KEY.KEY, }, }; } else { @@ -917,6 +922,8 @@ export class TypebotService { remoteJid: data.remoteJid, pushName: data.pushName || data.prefilledVariables?.pushName || '', instanceName: instance.instanceName, + serverUrl: this.configService.get('SERVER').URL, + apiKey: this.configService.get('AUTHENTICATION').API_KEY.KEY, }, }, }; @@ -936,6 +943,8 @@ export class TypebotService { remoteJid: data.remoteJid, pushName: data.pushName || '', instanceName: instance.instanceName, + serverUrl: this.configService.get('SERVER').URL, + apiKey: this.configService.get('AUTHENTICATION').API_KEY.KEY, }, awaitUser: false, typebotId: data.typebotId,