mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-19 09:53:36 -06:00
adjusts in typebot
This commit is contained in:
parent
4824ccafd6
commit
fa3306b0f4
@ -111,6 +111,7 @@ QRCODE_LIMIT=30
|
|||||||
QRCODE_COLOR='#175197'
|
QRCODE_COLOR='#175197'
|
||||||
|
|
||||||
TYPEBOT_ENABLED=false
|
TYPEBOT_ENABLED=false
|
||||||
|
TYPEBOT_SEND_MEDIA_BASE64=true
|
||||||
TYPEBOT_API_VERSION=latest
|
TYPEBOT_API_VERSION=latest
|
||||||
|
|
||||||
CHATWOOT_ENABLED=false
|
CHATWOOT_ENABLED=false
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Message, TypebotSession } from '@prisma/client';
|
import { Message, TypebotSession } from '@prisma/client';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import { Auth, ConfigService, Typebot } from '../../../../config/env.config';
|
import { ConfigService, Typebot } from '../../../../config/env.config';
|
||||||
import { Logger } from '../../../../config/logger.config';
|
import { Logger } from '../../../../config/logger.config';
|
||||||
import { InstanceDto } from '../../../dto/instance.dto';
|
import { InstanceDto } from '../../../dto/instance.dto';
|
||||||
import { PrismaRepository } from '../../../repository/repository.service';
|
import { PrismaRepository } from '../../../repository/repository.service';
|
||||||
@ -484,6 +484,15 @@ export class TypebotService {
|
|||||||
const remoteJid = data.remoteJid;
|
const remoteJid = data.remoteJid;
|
||||||
const status = data.status;
|
const status = data.status;
|
||||||
|
|
||||||
|
if (status === 'closed') {
|
||||||
|
await this.prismaRepository.typebotSession.deleteMany({
|
||||||
|
where: {
|
||||||
|
remoteJid: remoteJid,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return { typebot: { ...instance, typebot: { remoteJid: remoteJid, status: status } } };
|
||||||
|
} else {
|
||||||
const session = await this.prismaRepository.typebotSession.updateMany({
|
const session = await this.prismaRepository.typebotSession.updateMany({
|
||||||
where: {
|
where: {
|
||||||
instanceId: instanceId,
|
instanceId: instanceId,
|
||||||
@ -503,6 +512,7 @@ export class TypebotService {
|
|||||||
this.waMonitor.waInstances[instance.instanceName].sendDataWebhook(Events.TYPEBOT_CHANGE_STATUS, typebotData);
|
this.waMonitor.waInstances[instance.instanceName].sendDataWebhook(Events.TYPEBOT_CHANGE_STATUS, typebotData);
|
||||||
|
|
||||||
return { typebot: { ...instance, typebot: typebotData } };
|
return { typebot: { ...instance, typebot: typebotData } };
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(error);
|
this.logger.error(error);
|
||||||
throw new Error('Error changing status');
|
throw new Error('Error changing status');
|
||||||
@ -569,9 +579,6 @@ export class TypebotService {
|
|||||||
instanceName: instance.instanceName,
|
instanceName: instance.instanceName,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.configService.get<Auth>('AUTHENTICATION').EXPOSE_IN_FETCH_INSTANCES)
|
|
||||||
prefilledVariables['token'] = instance.token;
|
|
||||||
|
|
||||||
if (variables?.length) {
|
if (variables?.length) {
|
||||||
variables.forEach((variable: { name: string | number; value: string }) => {
|
variables.forEach((variable: { name: string | number; value: string }) => {
|
||||||
prefilledVariables[variable.name] = variable.value;
|
prefilledVariables[variable.name] = variable.value;
|
||||||
|
@ -1120,7 +1120,11 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
const contentMsg = received?.message[getContentType(received.message)] as any;
|
const contentMsg = received?.message[getContentType(received.message)] as any;
|
||||||
|
|
||||||
if (this.localWebhook.webhookBase64 === true && isMedia) {
|
if (
|
||||||
|
this.localWebhook.webhookBase64 === true ||
|
||||||
|
(this.configService.get<Typebot>('TYPEBOT').SEND_MEDIA_BASE64 && isMedia)
|
||||||
|
) {
|
||||||
|
console.log('Download media');
|
||||||
const buffer = await downloadMediaMessage(
|
const buffer = await downloadMediaMessage(
|
||||||
{ key: received.key, message: received?.message },
|
{ key: received.key, message: received?.message },
|
||||||
'buffer',
|
'buffer',
|
||||||
|
@ -176,7 +176,7 @@ export type SslConf = { PRIVKEY: string; FULLCHAIN: string };
|
|||||||
export type Webhook = { GLOBAL?: GlobalWebhook; EVENTS: EventsWebhook };
|
export type Webhook = { GLOBAL?: GlobalWebhook; EVENTS: EventsWebhook };
|
||||||
export type ConfigSessionPhone = { CLIENT: string; NAME: string; VERSION: string };
|
export type ConfigSessionPhone = { CLIENT: string; NAME: string; VERSION: string };
|
||||||
export type QrCode = { LIMIT: number; COLOR: string };
|
export type QrCode = { LIMIT: number; COLOR: string };
|
||||||
export type Typebot = { ENABLED: boolean; API_VERSION: string };
|
export type Typebot = { ENABLED: boolean; API_VERSION: string; SEND_MEDIA_BASE64: boolean };
|
||||||
export type Chatwoot = {
|
export type Chatwoot = {
|
||||||
ENABLED: boolean;
|
ENABLED: boolean;
|
||||||
MESSAGE_DELETE: boolean;
|
MESSAGE_DELETE: boolean;
|
||||||
@ -403,6 +403,7 @@ export class ConfigService {
|
|||||||
TYPEBOT: {
|
TYPEBOT: {
|
||||||
ENABLED: process.env?.TYPEBOT_ENABLED === 'true',
|
ENABLED: process.env?.TYPEBOT_ENABLED === 'true',
|
||||||
API_VERSION: process.env?.TYPEBOT_API_VERSION || 'old',
|
API_VERSION: process.env?.TYPEBOT_API_VERSION || 'old',
|
||||||
|
SEND_MEDIA_BASE64: process.env?.TYPEBOT_SEND_MEDIA_BASE64 === 'true',
|
||||||
},
|
},
|
||||||
CHATWOOT: {
|
CHATWOOT: {
|
||||||
ENABLED: process.env?.CHATWOOT_ENABLED === 'true',
|
ENABLED: process.env?.CHATWOOT_ENABLED === 'true',
|
||||||
|
Loading…
Reference in New Issue
Block a user