mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2026-03-21 20:18:40 -06:00
feat: implement Baileys channel services with advanced message handling, Typebot integration, and comprehensive API functionalities for chat, group, and business profiles.
This commit is contained in:
@@ -2229,7 +2229,10 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
if (!match) return undefined;
|
if (!match) return undefined;
|
||||||
|
|
||||||
const url = match[0];
|
// Trim common trailing punctuation that may follow URLs in natural text
|
||||||
|
const url = match[0].replace(/[.,);\]]+$/u, '');
|
||||||
|
if (!url) return undefined;
|
||||||
|
|
||||||
const previewData = await getLinkPreview(url, {
|
const previewData = await getLinkPreview(url, {
|
||||||
imagesPropertyType: 'og', // fetches only open-graph images
|
imagesPropertyType: 'og', // fetches only open-graph images
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -369,9 +369,33 @@ export class TypebotService extends BaseChatbotService<TypebotModel, any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (message.type === 'file' || message.type === 'embed') {
|
if (message.type === 'file' || message.type === 'embed') {
|
||||||
const mediaUrl = message.content.url;
|
const content = message.content as { url?: string; name?: string } | undefined;
|
||||||
|
if (!content?.url) {
|
||||||
|
sendTelemetry('/message/sendMediaMissingUrl');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const mediaUrl = content.url;
|
||||||
const mediaType = this.getMediaType(mediaUrl);
|
const mediaType = this.getMediaType(mediaUrl);
|
||||||
|
|
||||||
|
let fileName = content.name;
|
||||||
|
if (!fileName) {
|
||||||
|
try {
|
||||||
|
const urlObj = new URL(mediaUrl);
|
||||||
|
const path = urlObj.pathname || '';
|
||||||
|
const candidate = path.split('/').pop() || '';
|
||||||
|
if (candidate && candidate.includes('.')) {
|
||||||
|
fileName = candidate;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Ignore URL parsing failures
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fileName) {
|
||||||
|
fileName = mediaType && mediaType !== 'document' ? `media.${mediaType}` : 'attachment';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mediaType === 'audio') {
|
if (mediaType === 'audio') {
|
||||||
await instance.audioWhatsapp(
|
await instance.audioWhatsapp(
|
||||||
{
|
{
|
||||||
@@ -389,7 +413,7 @@ export class TypebotService extends BaseChatbotService<TypebotModel, any> {
|
|||||||
delay: settings?.delayMessage || 1000,
|
delay: settings?.delayMessage || 1000,
|
||||||
mediatype: mediaType || 'document',
|
mediatype: mediaType || 'document',
|
||||||
media: mediaUrl,
|
media: mediaUrl,
|
||||||
fileName: message.content.name || 'document.pdf',
|
fileName,
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
|
|||||||
Reference in New Issue
Block a user