Fix wrong usernames for admin logs

This commit is contained in:
Jared Schoeny 2025-12-13 16:43:35 -10:00
parent 3becfbd1ad
commit 39031290a0
2 changed files with 7 additions and 5 deletions

View File

@ -295,7 +295,7 @@ export async function approveHack(slug: string) {
// Check if hack exists
const { data: hack, error: hErr } = await supabase
.from("hacks")
.select("slug, approved, title")
.select("slug, approved, title, created_by")
.eq("slug", slug)
.maybeSingle();
if (hErr) return { ok: false, error: hErr.message } as const;
@ -320,7 +320,7 @@ export async function approveHack(slug: string) {
if (updateErr) return { ok: false, error: updateErr.message } as const;
if (process.env.DISCORD_WEBHOOK_ADMIN_URL) {
const { data: profile } = await supabase.from('profiles').select('*').eq('id', user.id).single();
const { data: profile } = await supabase.from('profiles').select('*').eq('id', hack.created_by).single();
const displayName = profile?.username ? `@${profile.username}` : user.id;
const embed: APIEmbed = {
title: `:tada: ${hack.title} :tada:`,

View File

@ -243,12 +243,14 @@ export async function confirmPatchUpload(args: { slug: string; objectKey: string
if (uErr) return { ok: false, error: uErr.message } as const;
if (process.env.DISCORD_WEBHOOK_ADMIN_URL) {
const { data: profile } = await supabase.from('profiles').select('*').eq('id', user.id).single();
const { data: profile } = await supabase.from('profiles').select('*').eq('id', hack.created_by).single();
const displayName = profile?.username ? `@${profile.username}` : hack.created_by;
const uploadedByDifferentUser = hack.created_by !== user.id;
const displayName = profile?.username ? `@${profile.username}` : user.id;
const embed: APIEmbed = args.firstUpload ? {
title: `:tada: ${hack.title}`,
description: `A new hack by **${displayName}** is pending approval by an admin.`,
description: `A new hack by **${displayName}** is pending approval by an admin.` + (uploadedByDifferentUser ? ` (Uploaded by ${user.id})` : ''),
color: 0x40f56a,
url: `${process.env.NEXT_PUBLIC_SITE_URL}/hack/${args.slug}`,
footer: {