This commit is contained in:
@@ -120,8 +120,8 @@ export const report = {
|
||||
}
|
||||
|
||||
sendWebhook(WebhookAction.Report, {
|
||||
reporter: report.reporter.username,
|
||||
reported: report.reported?.username ?? null,
|
||||
reporter: report.reporter.uuid,
|
||||
reported: report.reported?.uuid ?? null,
|
||||
reason: input.reason
|
||||
});
|
||||
},
|
||||
@@ -211,7 +211,7 @@ export const report = {
|
||||
|
||||
// send webhook in background
|
||||
sendWebhook(WebhookAction.Strike, {
|
||||
user: user!.uuid!
|
||||
uuid: user!.uuid!
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,8 @@ export const signup = {
|
||||
birthday: new Date(input.birthday).toISOString().slice(0, 10),
|
||||
telephone: input.phone,
|
||||
username: input.username,
|
||||
edition: input.edition
|
||||
edition: input.edition,
|
||||
uuid: uuid
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import { checkApiBasicAuth } from '@util/auth.ts';
|
||||
const postSchema = z.object({
|
||||
event: z.string(),
|
||||
title: z.string(),
|
||||
users: z.array(z.string())
|
||||
uuids: z.array(z.string())
|
||||
});
|
||||
|
||||
export const POST: APIRoute = async ({ request }) => {
|
||||
@@ -25,7 +25,7 @@ export const POST: APIRoute = async ({ request }) => {
|
||||
const feedbacks = await db.addUserFeedbacks({
|
||||
event: parsed.event,
|
||||
title: parsed.title,
|
||||
uuids: parsed.users
|
||||
uuids: parsed.uuids
|
||||
});
|
||||
|
||||
const response = feedbacks.map((feedback) => ({
|
||||
|
||||
@@ -3,23 +3,23 @@ import type { APIRoute } from 'astro';
|
||||
import { db } from '@db/database.ts';
|
||||
import { checkApiBasicAuth } from '@util/auth.ts';
|
||||
|
||||
const getSchema = z.object({
|
||||
user: z.string()
|
||||
const postSchema = z.object({
|
||||
uuid: z.string()
|
||||
});
|
||||
|
||||
export const GET: APIRoute = async ({ request }) => {
|
||||
export const POST: APIRoute = async ({ request }) => {
|
||||
if (!checkApiBasicAuth(request.headers)) {
|
||||
return new Response(null, { status: 401 });
|
||||
}
|
||||
|
||||
let parsed;
|
||||
try {
|
||||
parsed = await getSchema.parseAsync(await request.json());
|
||||
parsed = await postSchema.parseAsync(await request.json());
|
||||
} catch (_) {
|
||||
return new Response(null, { status: 400 });
|
||||
}
|
||||
|
||||
const user = await db.getUserByUuid({ uuid: parsed.user });
|
||||
const user = await db.getUserByUuid({ uuid: parsed.uuid });
|
||||
if (!user) return new Response(null, { status: 404 });
|
||||
|
||||
const strikes = await db.getStrikesByUserId({ userId: user.id });
|
||||
|
||||
@@ -16,6 +16,7 @@ export type WebhookActionType<T extends WebhookAction> = {
|
||||
telephone: string | null;
|
||||
username: string;
|
||||
edition: 'java' | 'bedrock';
|
||||
uuid: string | null;
|
||||
};
|
||||
[WebhookAction.Report]: {
|
||||
reporter: string | null;
|
||||
@@ -23,7 +24,7 @@ export type WebhookActionType<T extends WebhookAction> = {
|
||||
reason: string;
|
||||
};
|
||||
[WebhookAction.Strike]: {
|
||||
user: string;
|
||||
uuid: string;
|
||||
};
|
||||
}[T];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user