From f2550cabe2c4d9d012c3715bbb78465107dbed67 Mon Sep 17 00:00:00 2001 From: Jared Schoeny Date: Sun, 23 Aug 2026 08:31:31 -0600 Subject: [PATCH] Fix sending approved hack updates to the admin Discord path (#77) Approved version uploads now notify only the non-admin Hackdex webhook. Pending submissions still go to the review thread or admin webhook fallback. Also drop the tada emoji from the pending-approval embed. Co-authored-by: Cursor Agent --- src/app/submit/actions.ts | 50 ++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/app/submit/actions.ts b/src/app/submit/actions.ts index a428df1..bced923 100644 --- a/src/app/submit/actions.ts +++ b/src/app/submit/actions.ts @@ -335,7 +335,7 @@ export async function confirmPatchUpload(args: { slug: string; objectKey: string const displayName = profile?.username ? `@${profile.username}` : hack.created_by; const uploadedByDifferentUser = hack.created_by !== user.id; const embed: APIEmbed = args.firstUpload ? { - title: `:tada: ${hack.title}`, + title: hack.title, description: `A new hack by **${displayName}** is pending approval by an admin.` + (uploadedByDifferentUser ? ` (Uploaded by ${user.id})` : "") + (hack.verification_contact_info ? `\n\n**Verification contact info:**\n${hack.verification_contact_info}` : ""), @@ -354,31 +354,33 @@ export async function confirmPatchUpload(args: { slug: string; objectKey: string }, }; - let reviewThread = null; - if (!hack.is_archive) { - try { - reviewThread = await getHackReviewThread(args.slug); - if (!reviewThread && args.firstUpload) { - reviewThread = await ensureHackReviewThread({ - slug: args.slug, - title: hack.title, - author: displayName, - isClaimed: hack.assigned_admin !== null, - }); - } - } catch (error) { - console.error(`[HackReview] Failed to load or create the review thread for ${args.slug}:`, error); + if (hack.approved) { + if (process.env.DISCORD_WEBHOOK_HACKDEX_HACKS_URL) { + await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_HACKDEX_HACKS_URL, [embed]); + } + } else { + let reviewThread = null; + if (!hack.is_archive) { + try { + reviewThread = await getHackReviewThread(args.slug); + if (!reviewThread && args.firstUpload) { + reviewThread = await ensureHackReviewThread({ + slug: args.slug, + title: hack.title, + author: displayName, + isClaimed: hack.assigned_admin !== null, + }); + } + } catch (error) { + console.error(`[HackReview] Failed to load or create the review thread for ${args.slug}:`, error); + } } - } - if (reviewThread) { - await postHackReviewMessage(reviewThread, { embeds: [embed] }); - } else if (process.env.DISCORD_WEBHOOK_ADMIN_HACKS_URL) { - await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_ADMIN_HACKS_URL, [embed]); - } - - if (hack.approved && process.env.DISCORD_WEBHOOK_HACKDEX_HACKS_URL) { - await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_HACKDEX_HACKS_URL, [embed]); + if (reviewThread) { + await postHackReviewMessage(reviewThread, { embeds: [embed] }); + } else if (process.env.DISCORD_WEBHOOK_ADMIN_HACKS_URL) { + await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_ADMIN_HACKS_URL, [embed]); + } } // Redirect to versions page if not publishing automatically, otherwise to hack page