Integrate WhatsApp Gateway for mail notifications

This commit is contained in:
AyrisAI
2026-05-14 22:31:46 +03:00
parent ede38e80e4
commit b0139b6cab
2 changed files with 44 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
import { NextResponse } from 'next/server';
import { prisma } from '@/lib/prisma';
import { sendTelegramNotification } from '@/lib/notifications';
import { sendWA } from '@/lib/whatsapp';
// Bu kısım normalde .env içinde olmalı
const WEBHOOK_SECRET = process.env.WEBHOOK_SIGNAL_SECRET || 'besiktasK1903*';
@@ -74,7 +75,14 @@ export async function POST(request: Request) {
"" // Analiz bilgisini kaldırdık
);
// 4. Bildirim Logu
// 4. Bildirim Gönder (WhatsApp)
// Şu an için varsayılan numaraya gönderiyoruz, ilerde User modeline alan eklenebilir.
const waNumber = process.env.DEFAULT_WHATSAPP_NUMBER || '905543765103';
const waMessage = `📩 *Yeni E-posta*\n\n*Gönderen:* ${mailData.from}\n*Konu:* ${mailData.subject}\n*Alıcı:* ${to}\n\n_AyrisMail Central_`;
await sendWA(waNumber, waMessage);
// 5. Bildirim Logu
await prisma.notificationLog.create({
data: {
mailbox: to,