mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-24 17:38:40 -06:00
Correção do Markdown na integração N8N
## Descrição Esta PR implementa melhorias no processamento de mensagens do serviço N8n, especificamente no método `sendMessageWhatsApp`. As alterações visam melhorar o tratamento de links e formatação markdown nas mensagens. ## Mudanças - Ajustada a desestruturação do objeto `match` para capturar corretamente o texto completo do link markdown - Modificado o tratamento de links que não são mídia para preservar a formatação original - Mantida a expressão regular para detecção de links markdown ## Impacto - Mensagens com links markdown agora são processadas de forma mais consistente - A formatação original dos links é preservada quando não são tratados como mídia - Melhor tratamento de casos onde o link não corresponde a um tipo de mídia suportado
This commit is contained in:
parent
7cccda10bb
commit
833cf06d4c
@ -194,7 +194,7 @@ export class N8nService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async sendMessageWhatsApp(instance: any, remoteJid: string, message: string, settings: N8nSetting) {
|
private async sendMessageWhatsApp(instance: any, remoteJid: string, message: string, settings: N8nSetting) {
|
||||||
const linkRegex = /(!?)\[(.*?)\]\((.*?)\)/g;
|
const linkRegex = /!?\[(.*?)\]\((.*?)\)/g;
|
||||||
let textBuffer = '';
|
let textBuffer = '';
|
||||||
let lastIndex = 0;
|
let lastIndex = 0;
|
||||||
let match: RegExpExecArray | null;
|
let match: RegExpExecArray | null;
|
||||||
@ -211,7 +211,7 @@ export class N8nService {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
while ((match = linkRegex.exec(message)) !== null) {
|
while ((match = linkRegex.exec(message)) !== null) {
|
||||||
const [altText, url] = match;
|
const [fullMatch, altText, url] = match;
|
||||||
const mediaType = getMediaType(url);
|
const mediaType = getMediaType(url);
|
||||||
const beforeText = message.slice(lastIndex, match.index);
|
const beforeText = message.slice(lastIndex, match.index);
|
||||||
if (beforeText) {
|
if (beforeText) {
|
||||||
@ -282,7 +282,7 @@ export class N8nService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
textBuffer += `[${altText}](${url})`;
|
textBuffer += fullMatch;
|
||||||
}
|
}
|
||||||
lastIndex = linkRegex.lastIndex;
|
lastIndex = linkRegex.lastIndex;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user