Update signal webhook to accept direct content and send TG notifications
This commit is contained in:
@@ -15,7 +15,7 @@ export async function POST(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
const { to, event, timestamp } = body;
|
const { to, event, subject: incomingSubject, body: incomingBody, from: incomingFrom } = body;
|
||||||
|
|
||||||
console.log(`📩 Webhook Sinyali Alındı! Alıcı: ${to}`);
|
console.log(`📩 Webhook Sinyali Alındı! Alıcı: ${to}`);
|
||||||
|
|
||||||
@@ -31,17 +31,27 @@ export async function POST(request: Request) {
|
|||||||
return NextResponse.json({ success: true, message: 'No mapping found' });
|
return NextResponse.json({ success: true, message: 'No mapping found' });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Mailcow'dan son maili çek
|
// 2. Mail İçeriğini Belirle (Ya gelen body'den ya da IMAP'ten)
|
||||||
// Not: Master password kullanılıyorsa format 'user@domain.tld*master@domain.tld' şeklindedir
|
let mailData = null;
|
||||||
const loginUser = IMAP_PASSWORD ? `${to}*${process.env.MAILCOW_MASTER_USER || 'admin'}` : to;
|
|
||||||
const mailData = await getLatestEmail(to, IMAP_PASSWORD);
|
if (incomingSubject && incomingBody) {
|
||||||
|
console.log("[Signal] İçerik worker'dan hazır geldi.");
|
||||||
|
mailData = {
|
||||||
|
subject: incomingSubject,
|
||||||
|
text: incomingBody,
|
||||||
|
from: incomingFrom || "Bilinmiyor"
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
console.log("[Signal] İçerik eksik, IMAP'e gidiliyor...");
|
||||||
|
mailData = await getLatestEmail(to, IMAP_PASSWORD);
|
||||||
|
}
|
||||||
|
|
||||||
if (!mailData) {
|
if (!mailData) {
|
||||||
console.error(`[Signal] Mail içeriği çekilemedi: ${to}`);
|
console.error(`[Signal] Mail içeriği çekilemedi: ${to}`);
|
||||||
return NextResponse.json({ success: false, error: 'Could not fetch mail' }, { status: 500 });
|
return NextResponse.json({ success: false, error: 'Could not fetch mail' }, { status: 500 });
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[Signal] Mail Çekildi: "${mailData.subject}"`);
|
console.log(`[Signal] Mail İşleniyor: "${mailData.subject}"`);
|
||||||
|
|
||||||
// 3. İçerik Analizi (BMW, Penti vb.)
|
// 3. İçerik Analizi (BMW, Penti vb.)
|
||||||
let processed = false;
|
let processed = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user