This commit is contained in:
romantarkin 2025-08-18 15:03:21 +05:00
parent 30922e00b1
commit 0c337bdbe6

View File

@ -259,14 +259,17 @@ async function processEmailTask(task, topic) {
});
console.log(`[DynamicConsumer] Transporter created successfully`);
// Извлекаем домен из email
const domain = smtp.from_email.split('@')[1];
// Добавляем трекинг-пиксель для отслеживания открытия письма
const trackingPixel = `<img src="http://${smtp.from_email}/api/mail/track/open/${deliveryLog.id}" width="1" height="1" style="display:none;" />`;
const trackingPixel = `<img src="http://${domain}/api/mail/track/open/${deliveryLog.id}" width="1" height="1" style="display:none;" />`;
// Обрабатываем ссылки для отслеживания кликов
const htmlWithClickTracking = task.html.replace(
/<a\s+href=["']([^"']+)["']/gi,
(match, url) => {
const trackingUrl = `http://${smtp.from_email}/api/mail/track/click/${deliveryLog.id}?url=${encodeURIComponent(url)}`;
const trackingUrl = `http://${domain}/api/mail/track/click/${deliveryLog.id}?url=${encodeURIComponent(url)}`;
return `<a href="${trackingUrl}"`;
}
);