chore: remove Telegram notification from contact form
All checks were successful
CI / CD / test-build (push) Successful in 10m15s
CI / CD / deploy-dev (push) Successful in 1m15s
CI / CD / deploy-production (push) Has been skipped

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 00:19:52 +01:00
parent 63960f7581
commit dda996f0f8

View File

@@ -18,61 +18,6 @@ function escapeHtml(input: string): string {
.replace(/'/g, "&#39;");
}
function escapeHtmlTg(input: string): string {
return input.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}
async function sendTelegramNotification(data: {
name: string;
email: string;
subject: string;
message: string;
sentAt: string;
}): Promise<void> {
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 = [
"🔔 <b>Neue Kontaktanfrage</b>",
"",
`👤 <b>Name:</b> ${escapeHtmlTg(data.name)}`,
`📧 <b>Email:</b> ${escapeHtmlTg(data.email)}`,
`📌 <b>Betreff:</b> ${escapeHtmlTg(data.subject)}`,
"",
"💬 <b>Nachricht:</b>",
`<i>${escapeHtmlTg(preview)}</i>`,
"",
`🕐 <i>${escapeHtmlTg(data.sentAt)}</i>`,
].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 } });