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%
This commit is contained in:
Davidson Gomes 2024-07-18 08:15:53 -03:00
parent b907d85a7e
commit 9aa2b1b3bf
2 changed files with 10 additions and 49 deletions

View File

@ -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 }}

View File

@ -1,9 +1,10 @@
import { Message, Typebot as TypebotModel, TypebotSession } from '@prisma/client'; import { Message, Typebot as TypebotModel, TypebotSession } from '@prisma/client';
import axios from 'axios'; 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 { Logger } from '../../../../config/logger.config';
import { sendTelemetry } from '../../../../utils/sendTelemetry'; import { sendTelemetry } from '../../../../utils/sendTelemetry';
import { ServerUP } from '../../../../utils/server-up';
import { InstanceDto } from '../../../dto/instance.dto'; import { InstanceDto } from '../../../dto/instance.dto';
import { PrismaRepository } from '../../../repository/repository.service'; import { PrismaRepository } from '../../../repository/repository.service';
import { WAMonitoringService } from '../../../services/monitor.service'; import { WAMonitoringService } from '../../../services/monitor.service';
@ -710,6 +711,8 @@ export class TypebotService {
const prefilledVariables = { const prefilledVariables = {
remoteJid: remoteJid, remoteJid: remoteJid,
instanceName: instance.instanceName, instanceName: instance.instanceName,
serverUrl: this.configService.get<HttpServer>('SERVER').URL,
apiKey: this.configService.get<Auth>('AUTHENTICATION').API_KEY.KEY,
}; };
if (variables?.length) { if (variables?.length) {
@ -904,6 +907,8 @@ export class TypebotService {
remoteJid: data.remoteJid, remoteJid: data.remoteJid,
pushName: data.pushName || data.prefilledVariables?.pushName || '', pushName: data.pushName || data.prefilledVariables?.pushName || '',
instanceName: instance.instanceName, instanceName: instance.instanceName,
serverUrl: this.configService.get<HttpServer>('SERVER').URL,
apiKey: this.configService.get<Auth>('AUTHENTICATION').API_KEY.KEY,
}, },
}; };
} else { } else {
@ -917,6 +922,8 @@ export class TypebotService {
remoteJid: data.remoteJid, remoteJid: data.remoteJid,
pushName: data.pushName || data.prefilledVariables?.pushName || '', pushName: data.pushName || data.prefilledVariables?.pushName || '',
instanceName: instance.instanceName, instanceName: instance.instanceName,
serverUrl: this.configService.get<HttpServer>('SERVER').URL,
apiKey: this.configService.get<Auth>('AUTHENTICATION').API_KEY.KEY,
}, },
}, },
}; };
@ -936,6 +943,8 @@ export class TypebotService {
remoteJid: data.remoteJid, remoteJid: data.remoteJid,
pushName: data.pushName || '', pushName: data.pushName || '',
instanceName: instance.instanceName, instanceName: instance.instanceName,
serverUrl: this.configService.get<HttpServer>('SERVER').URL,
apiKey: this.configService.get<Auth>('AUTHENTICATION').API_KEY.KEY,
}, },
awaitUser: false, awaitUser: false,
typebotId: data.typebotId, typebotId: data.typebotId,