mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-22 20:12:02 -06:00
fix: duplicated bot when use startTypebot
This commit is contained in:
parent
e8fa952de5
commit
c531906de2
@ -1037,6 +1037,11 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
source: getDevice(received.key.id),
|
||||
};
|
||||
|
||||
if (messageRaw.message.extendedTextMessage) {
|
||||
messageRaw.message.conversation = messageRaw.message.extendedTextMessage.text;
|
||||
delete messageRaw.message.extendedTextMessage;
|
||||
}
|
||||
|
||||
const isMedia =
|
||||
received?.message?.imageMessage ||
|
||||
received?.message?.videoMessage ||
|
||||
@ -1937,6 +1942,11 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
source: getDevice(messageSent.key.id),
|
||||
};
|
||||
|
||||
if (messageRaw.message.extendedTextMessage) {
|
||||
messageRaw.message.conversation = messageRaw.message.extendedTextMessage.text;
|
||||
delete messageRaw.message.extendedTextMessage;
|
||||
}
|
||||
|
||||
this.logger.log(messageRaw);
|
||||
|
||||
this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);
|
||||
|
@ -577,35 +577,7 @@ export class TypebotController extends ChatbotController implements ChatbotContr
|
||||
},
|
||||
});
|
||||
|
||||
if (defaultSettingCheck?.ignoreJids) {
|
||||
const ignoreJids: any = defaultSettingCheck.ignoreJids;
|
||||
|
||||
let ignoreGroups = false;
|
||||
let ignoreContacts = false;
|
||||
|
||||
if (ignoreJids.includes('@g.us')) {
|
||||
ignoreGroups = true;
|
||||
}
|
||||
|
||||
if (ignoreJids.includes('@s.whatsapp.net')) {
|
||||
ignoreContacts = true;
|
||||
}
|
||||
|
||||
if (ignoreGroups && remoteJid.includes('@g.us')) {
|
||||
this.logger.warn('Ignoring message from group: ' + remoteJid);
|
||||
throw new Error('Group not allowed');
|
||||
}
|
||||
|
||||
if (ignoreContacts && remoteJid.includes('@s.whatsapp.net')) {
|
||||
this.logger.warn('Ignoring message from contact: ' + remoteJid);
|
||||
throw new Error('Contact not allowed');
|
||||
}
|
||||
|
||||
if (ignoreJids.includes(remoteJid)) {
|
||||
this.logger.warn('Ignoring message from jid: ' + remoteJid);
|
||||
throw new Error('Jid not allowed');
|
||||
}
|
||||
}
|
||||
if (this.checkIgnoreJids(defaultSettingCheck?.ignoreJids, remoteJid)) throw new Error('Jid not allowed');
|
||||
|
||||
if (
|
||||
!expire ||
|
||||
@ -661,8 +633,18 @@ export class TypebotController extends ChatbotController implements ChatbotContr
|
||||
});
|
||||
|
||||
if (!findBot) {
|
||||
findBot = await this.botRepository.create({
|
||||
data: {
|
||||
findBot = await this.botRepository.upsert({
|
||||
where: {
|
||||
url_typebot_instanceId: {
|
||||
url: url,
|
||||
typebot: typebot,
|
||||
instanceId: instanceData.id,
|
||||
},
|
||||
},
|
||||
update: {
|
||||
enabled: true,
|
||||
},
|
||||
create: {
|
||||
enabled: true,
|
||||
url: url,
|
||||
typebot: typebot,
|
||||
|
Loading…
Reference in New Issue
Block a user