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 { to, event, timestamp } = body;
|
||||
const { to, event, subject: incomingSubject, body: incomingBody, from: incomingFrom } = body;
|
||||
|
||||
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' });
|
||||
}
|
||||
|
||||
// 2. Mailcow'dan son maili çek
|
||||
// Not: Master password kullanılıyorsa format 'user@domain.tld*master@domain.tld' şeklindedir
|
||||
const loginUser = IMAP_PASSWORD ? `${to}*${process.env.MAILCOW_MASTER_USER || 'admin'}` : to;
|
||||
const mailData = await getLatestEmail(to, IMAP_PASSWORD);
|
||||
// 2. Mail İçeriğini Belirle (Ya gelen body'den ya da IMAP'ten)
|
||||
let mailData = null;
|
||||
|
||||
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) {
|
||||
console.error(`[Signal] Mail içeriği çekilemedi: ${to}`);
|
||||
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.)
|
||||
let processed = false;
|
||||
|
||||
Reference in New Issue
Block a user