mirror of
https://github.com/Hackdex-App/hackdex-website.git
synced 2026-04-16 18:16:56 -05:00
Fix wrong usernames for admin logs
This commit is contained in:
parent
3becfbd1ad
commit
39031290a0
|
|
@ -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:`,
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user