From 6aa3eaea25ff71678f5951eeb73210ef0599d603 Mon Sep 17 00:00:00 2001 From: jschoeny Date: Thu, 1 Jan 2026 14:25:38 -1000 Subject: [PATCH] Add admin reports discord webhook --- src/app/contact/actions.ts | 21 +++++++++++++++++++++ src/app/hack/[slug]/actions.ts | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/app/contact/actions.ts b/src/app/contact/actions.ts index 1e02058..edd4da3 100644 --- a/src/app/contact/actions.ts +++ b/src/app/contact/actions.ts @@ -1,6 +1,8 @@ "use server"; import nodemailer from "nodemailer"; +import { APIEmbed } from "discord-api-types/v10"; +import { sendDiscordMessageEmbed } from "@/utils/discord"; export interface ContactActionState { error: string | null; @@ -102,6 +104,25 @@ export async function sendContact(prev: ContactActionState, formData: FormData): text: confirmationMessage, }); + // Send Discord notification + if (process.env.DISCORD_WEBHOOK_ADMIN_REPORTS_URL) { + const embed: APIEmbed = { + title: `📧 ${topicLabels[topic]}`, + description: message.length > 4096 ? message.substring(0, 4093) + "..." : message, + color: topic === "security" ? 0xff0000 : topic === "bug" ? 0xffa500 : 0x3498db, + fields: [ + ...(name ? [{ name: "Name", value: name, inline: true }] : []), + { name: "Email", value: email, inline: true }, + ...(contextUrl ? [{ name: "Related URL", value: contextUrl, inline: false }] : []), + ], + footer: { + text: `Ticket #${ticketId}`, + }, + timestamp: new Date().toISOString(), + }; + await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_ADMIN_REPORTS_URL, [embed]); + } + return { error: null, success: `Your message was sent. Ticket #${ticketId}.` }; } catch (err: unknown) { const message = err instanceof Error ? err.message : "Failed to send message."; diff --git a/src/app/hack/[slug]/actions.ts b/src/app/hack/[slug]/actions.ts index 736e9da..fff8265 100644 --- a/src/app/hack/[slug]/actions.ts +++ b/src/app/hack/[slug]/actions.ts @@ -368,9 +368,9 @@ export async function submitHackReport(data: { } // Send Discord webhook - if (process.env.DISCORD_WEBHOOK_ADMIN_URL) { + if (process.env.DISCORD_WEBHOOK_ADMIN_REPORTS_URL) { try { - await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_ADMIN_URL, [ + await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_ADMIN_REPORTS_URL, [ { title: "Hack Report", description: `A new report has been submitted for [${hack.title}](${hackUrl})`,