fix: StopBotFromMe working with chatwoot

This commit is contained in:
Davidson Gomes 2024-08-09 09:55:50 -03:00
parent 0dfbed4eb9
commit e7ff09752e
6 changed files with 84 additions and 51 deletions

View File

@ -12,6 +12,7 @@
* Fixed loading of selects in the manager
* Add restart button to sessions screen
* Adjustments to docker files
* StopBotFromMe working with chatwoot
# 2.0.8-rc (2024-08-08 20:23)

View File

@ -977,23 +977,14 @@ export class DifyService {
};
if (stopBotFromMe && key.fromMe && session) {
if (keepOpen) {
await this.prismaRepository.difySession.update({
where: {
id: session.id,
},
data: {
status: 'closed',
},
});
} else {
await this.prismaRepository.difySession.deleteMany({
where: {
difyId: findDify.id,
remoteJid: remoteJid,
},
});
}
await this.prismaRepository.difySession.update({
where: {
id: session.id,
},
data: {
status: 'paused',
},
});
return;
}

View File

@ -1180,23 +1180,14 @@ export class OpenaiService {
};
if (stopBotFromMe && key.fromMe && session) {
if (keepOpen) {
await this.prismaRepository.openaiSession.update({
where: {
id: session.id,
},
data: {
status: 'closed',
},
});
} else {
await this.prismaRepository.openaiSession.deleteMany({
where: {
openaiBotId: findOpenai.id,
remoteJid: remoteJid,
},
});
}
await this.prismaRepository.openaiSession.update({
where: {
id: session.id,
},
data: {
status: 'paused',
},
});
return;
}

View File

@ -1559,23 +1559,14 @@ export class TypebotService {
};
if (stopBotFromMe && key.fromMe && session) {
if (keepOpen) {
await this.prismaRepository.typebotSession.update({
where: {
id: session.id,
},
data: {
status: 'closed',
},
});
} else {
await this.prismaRepository.typebotSession.deleteMany({
where: {
typebotId: findTypebot.id,
remoteJid: remoteJid,
},
});
}
await this.prismaRepository.typebotSession.update({
where: {
id: session.id,
},
data: {
status: 'paused',
},
});
return;
}

View File

@ -2014,6 +2014,36 @@ export class BaileysStartupService extends ChannelStartupService {
);
}
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled && isIntegration) {
if (this.configService.get<Typebot>('TYPEBOT').ENABLED) {
if (messageRaw.messageType !== 'reactionMessage')
await this.typebotService.sendTypebot(
{ instanceName: this.instance.name, instanceId: this.instanceId },
messageRaw.key.remoteJid,
messageRaw,
);
}
if (this.configService.get<Openai>('OPENAI').ENABLED) {
if (messageRaw.messageType !== 'reactionMessage')
await this.openaiService.sendOpenai(
{ instanceName: this.instance.name, instanceId: this.instanceId },
messageRaw.key.remoteJid,
messageRaw,
);
}
if (this.configService.get<Dify>('DIFY').ENABLED) {
console.log('DIFY messageRaw', messageRaw);
if (messageRaw.messageType !== 'reactionMessage')
await this.difyService.sendDify(
{ instanceName: this.instance.name, instanceId: this.instanceId },
messageRaw.key.remoteJid,
messageRaw,
);
}
}
if (this.configService.get<Database>('DATABASE').SAVE_DATA.NEW_MESSAGE)
await this.prismaRepository.message.create({
data: messageRaw,

View File

@ -948,6 +948,35 @@ export class BusinessStartupService extends ChannelStartupService {
);
}
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled && isIntegration) {
if (this.configService.get<Typebot>('TYPEBOT').ENABLED) {
if (messageRaw.messageType !== 'reactionMessage')
await this.typebotService.sendTypebot(
{ instanceName: this.instance.name, instanceId: this.instanceId },
messageRaw.key.remoteJid,
messageRaw,
);
}
if (this.configService.get<Openai>('OPENAI').ENABLED) {
if (messageRaw.messageType !== 'reactionMessage')
await this.openaiService.sendOpenai(
{ instanceName: this.instance.name, instanceId: this.instanceId },
messageRaw.key.remoteJid,
messageRaw,
);
}
if (this.configService.get<Dify>('DIFY').ENABLED) {
if (messageRaw.messageType !== 'reactionMessage')
await this.difyService.sendDify(
{ instanceName: this.instance.name, instanceId: this.instanceId },
messageRaw.key.remoteJid,
messageRaw,
);
}
}
await this.prismaRepository.message.create({
data: messageRaw,
});