diff --git a/app/api/email/route.tsx b/app/api/email/route.tsx index 2b11d40..1731a06 100644 --- a/app/api/email/route.tsx +++ b/app/api/email/route.tsx @@ -18,61 +18,6 @@ function escapeHtml(input: string): string { .replace(/'/g, "'"); } -function escapeHtmlTg(input: string): string { - return input.replace(/&/g, "&").replace(//g, ">"); -} - -async function sendTelegramNotification(data: { - name: string; - email: string; - subject: string; - message: string; - sentAt: string; -}): Promise { - const token = process.env.TELEGRAM_BOT_TOKEN; - const chatId = process.env.TELEGRAM_CHAT_ID; - if (!token || !chatId) return; - - const preview = data.message.length > 400 - ? data.message.slice(0, 400) + "…" - : data.message; - - const text = [ - "🔔 Neue Kontaktanfrage", - "", - `👤 Name: ${escapeHtmlTg(data.name)}`, - `📧 Email: ${escapeHtmlTg(data.email)}`, - `📌 Betreff: ${escapeHtmlTg(data.subject)}`, - "", - "💬 Nachricht:", - `${escapeHtmlTg(preview)}`, - "", - `🕐 ${escapeHtmlTg(data.sentAt)}`, - ].join("\n"); - - try { - await fetch(`https://api.telegram.org/bot${token}/sendMessage`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ - chat_id: chatId, - text, - parse_mode: "HTML", - reply_markup: { - inline_keyboard: [[ - { - text: "📧 Per E-Mail antworten", - url: `mailto:${data.email}?subject=${encodeURIComponent("Re: " + data.subject)}`, - }, - ]], - }, - }), - signal: AbortSignal.timeout(5000), - }); - } catch { - // Never fail the contact form because of Telegram - } -} function buildNotificationEmail(opts: { name: string; @@ -309,9 +254,6 @@ export async function POST(request: NextRequest) { } } - // Telegram notification — fire and forget, never blocks the response - sendTelegramNotification({ name, email, subject, message, sentAt }).catch(() => {}); - // Save to DB try { await prisma.contact.create({ data: { name, email, subject, message, responded: false } });