mirror of
https://github.com/Hackdex-App/hackdex-website.git
synced 2026-08-22 08:34:13 -05:00
Better organize discord admin webhooks
This commit is contained in:
@@ -55,7 +55,7 @@ export async function setupProfile(username: string): Promise<UpdateState> {
|
||||
await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_ADMIN_URL, [
|
||||
{
|
||||
title: 'New Profile Setup',
|
||||
description: `A new user (\`${user.id}\`) has setup their profile with the username: \`@${username}\``,
|
||||
description: `A new user (\`${user.id}\`) has created an account with the username: \`@${username}\``,
|
||||
color: 0x40f56a,
|
||||
footer: {
|
||||
text: 'This message brought to you by Hackdex'
|
||||
|
||||
@@ -319,7 +319,7 @@ export async function approveHack(slug: string) {
|
||||
|
||||
if (updateErr) return { ok: false, error: updateErr.message } as const;
|
||||
|
||||
if (process.env.DISCORD_WEBHOOK_ADMIN_URL) {
|
||||
if (process.env.DISCORD_WEBHOOK_HACKDEX_HACKS_URL) {
|
||||
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 = {
|
||||
@@ -331,7 +331,7 @@ export async function approveHack(slug: string) {
|
||||
text: `This message brought to you by Hackdex`
|
||||
}
|
||||
}
|
||||
await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_ADMIN_URL, [
|
||||
await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_HACKDEX_HACKS_URL, [
|
||||
embed,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -72,26 +72,12 @@ export async function signup(state: AuthActionState, payload: FormData) {
|
||||
return { error: passwordError };
|
||||
}
|
||||
|
||||
const { data: signUpResult, error } = await supabase.auth.signUp(data)
|
||||
const { error } = await supabase.auth.signUp(data)
|
||||
|
||||
if (error) {
|
||||
return { error: getErrorMessage(error) };
|
||||
}
|
||||
|
||||
const userId = signUpResult.user?.id || null
|
||||
if (process.env.DISCORD_WEBHOOK_ADMIN_URL) {
|
||||
await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_ADMIN_URL, [
|
||||
{
|
||||
title: 'New User Signup',
|
||||
description: `A new user (\`${userId}\`) has signed up.`,
|
||||
color: 0x40f56a,
|
||||
footer: {
|
||||
text: 'A notification will be sent when this user has created their profile'
|
||||
}
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
revalidatePath('/', 'layout');
|
||||
const redirectTo = (payload.get('redirectTo') as string | null) || null
|
||||
const isValidInternalPath = redirectTo && redirectTo.startsWith('/') && !redirectTo.startsWith('//')
|
||||
|
||||
@@ -110,7 +110,7 @@ export async function prepareSubmission(formData: FormData) {
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.DISCORD_WEBHOOK_ADMIN_URL) {
|
||||
if (process.env.DISCORD_WEBHOOK_ADMIN_HACKS_URL) {
|
||||
const { data: profile } = await supabase.from('profiles').select('*').eq('id', user.id).single();
|
||||
const displayName = profile?.username ? `@${profile.username}` : user.id;
|
||||
|
||||
@@ -123,7 +123,7 @@ export async function prepareSubmission(formData: FormData) {
|
||||
text: `This message brought to you by Hackdex`
|
||||
}
|
||||
}
|
||||
await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_ADMIN_URL, [
|
||||
await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_ADMIN_HACKS_URL, [
|
||||
embed,
|
||||
]);
|
||||
}
|
||||
@@ -260,9 +260,8 @@ export async function confirmPatchUpload(args: { slug: string; objectKey: string
|
||||
.eq("slug", args.slug);
|
||||
if (uErr) return { ok: false, error: uErr.message } as const;
|
||||
|
||||
if (process.env.DISCORD_WEBHOOK_ADMIN_URL) {
|
||||
if (process.env.DISCORD_WEBHOOK_ADMIN_HACKS_URL) {
|
||||
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;
|
||||
|
||||
@@ -284,7 +283,11 @@ export async function confirmPatchUpload(args: { slug: string; objectKey: string
|
||||
}
|
||||
}
|
||||
|
||||
await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_ADMIN_URL, [
|
||||
const webhookUrl = args.firstUpload ?
|
||||
process.env.DISCORD_WEBHOOK_ADMIN_HACKS_URL :
|
||||
process.env.DISCORD_WEBHOOK_HACKDEX_HACKS_URL || process.env.DISCORD_WEBHOOK_ADMIN_HACKS_URL;
|
||||
|
||||
await sendDiscordMessageEmbed(webhookUrl, [
|
||||
embed,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user