chore: remove Telegram notification from contact form
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,61 +18,6 @@ function escapeHtml(input: string): string {
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
function escapeHtmlTg(input: string): string {
|
||||
return input.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
||||
}
|
||||
|
||||
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 } });
|
||||
|
||||
Reference in New Issue
Block a user