mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-24 17:38:40 -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),
|
source: getDevice(received.key.id),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (messageRaw.message.extendedTextMessage) {
|
||||||
|
messageRaw.message.conversation = messageRaw.message.extendedTextMessage.text;
|
||||||
|
delete messageRaw.message.extendedTextMessage;
|
||||||
|
}
|
||||||
|
|
||||||
const isMedia =
|
const isMedia =
|
||||||
received?.message?.imageMessage ||
|
received?.message?.imageMessage ||
|
||||||
received?.message?.videoMessage ||
|
received?.message?.videoMessage ||
|
||||||
@ -1937,6 +1942,11 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
source: getDevice(messageSent.key.id),
|
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.logger.log(messageRaw);
|
||||||
|
|
||||||
this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);
|
this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);
|
||||||
|
@ -577,35 +577,7 @@ export class TypebotController extends ChatbotController implements ChatbotContr
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (defaultSettingCheck?.ignoreJids) {
|
if (this.checkIgnoreJids(defaultSettingCheck?.ignoreJids, remoteJid)) throw new Error('Jid not allowed');
|
||||||
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 (
|
if (
|
||||||
!expire ||
|
!expire ||
|
||||||
@ -661,8 +633,18 @@ export class TypebotController extends ChatbotController implements ChatbotContr
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!findBot) {
|
if (!findBot) {
|
||||||
findBot = await this.botRepository.create({
|
findBot = await this.botRepository.upsert({
|
||||||
data: {
|
where: {
|
||||||
|
url_typebot_instanceId: {
|
||||||
|
url: url,
|
||||||
|
typebot: typebot,
|
||||||
|
instanceId: instanceData.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
update: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
create: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
url: url,
|
url: url,
|
||||||
typebot: typebot,
|
typebot: typebot,
|
||||||
|
Loading…
Reference in New Issue
Block a user