This commit is contained in:
18
README.md
18
README.md
@@ -101,6 +101,8 @@
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Response Codes
|
||||||
|
|
||||||
| http code | beschreibung |
|
| http code | beschreibung |
|
||||||
| --------- | ----------------------------------------------------------------- |
|
| --------- | ----------------------------------------------------------------- |
|
||||||
| 200 | / |
|
| 200 | / |
|
||||||
@@ -115,17 +117,19 @@
|
|||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><code>GET</code> <code>/api/player</code> (Status eines Spielers)</summary>
|
<summary><code>POST</code> <code>/api/player</code> (Status eines Spielers)</summary>
|
||||||
|
|
||||||
##### Request Body
|
##### Request Body
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
// UUID eines Spielers
|
// UUID eines Spielers
|
||||||
"user": string
|
"uuid": string
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Response Codes
|
||||||
|
|
||||||
| http code | beschreibung |
|
| http code | beschreibung |
|
||||||
| --------- | ------------------------------------------ |
|
| --------- | ------------------------------------------ |
|
||||||
| 200 | / |
|
| 200 | / |
|
||||||
@@ -161,8 +165,8 @@ Das Webhook wir so oft gesendet, bis der angegebene Webhook Endpoint eine Respon
|
|||||||
|
|
||||||
Alle Webhooks:
|
Alle Webhooks:
|
||||||
|
|
||||||
| Beschreibung | HTTP Header | Body |
|
| Beschreibung | HTTP Header | Body |
|
||||||
| ------------------------------------- | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ------------------------------------- | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Ein neuer Nutzer hat sich registriert | <pre>x-webhook-action: signup</pre> | <pre>{<br> // Vorname des Nutzers<br> firstname: string,<br> // Nachname des Nutzers<br> lastname: string,<br> //Geburtstag des Nutzers im YYYY-MM-DD format<br> birthday: string,<br> // Telefonnummer des Nutzers. `null` wenn keine angegeben wurde<br> telephone: string \| null,<br> // Spielername des Nutzers<br> username: string,<br> // Minecraft-Edition des Nutzers<br> edition: 'java' \| 'bedrock'</pre> |
|
| Ein neuer Nutzer hat sich registriert | <pre>x-webhook-action: signup</pre> | <pre>{<br> // Vorname des Nutzers<br> firstname: string,<br> // Nachname des Nutzers<br> lastname: string,<br> //Geburtstag des Nutzers im YYYY-MM-DD format<br> birthday: string,<br> // Telefonnummer des Nutzers. `null` wenn keine angegeben wurde<br> telephone: string \| null,<br> // Spielername des Nutzers<br> username: string,<br> // Minecraft-Edition des Nutzers<br> edition: 'java' \| 'bedrock'<br> //UUID des Nutzers. null wenn keine UUID ermittelt werden konnte<br> uuid: string \| null<br>}</pre> |
|
||||||
| Ein neuer Report wurde erstellt | <pre>x-webhook-action: report</pre> | <pre>{<br> // Username des Reporters. `null` wenn der Report vom System gemacht wurde<br> reporter: string \| null,<br> // Username des reporteten Spielers. `null` wenn Spieler unbekannt ist<br> reported: string \| null,<br> // Grund des Reports<br> reason: string<br>}</pre> |
|
| Ein neuer Report wurde erstellt | <pre>x-webhook-action: report</pre> | <pre>{<br> // Username des Reporters. `null` wenn der Report vom System gemacht wurde<br> reporter: string \| null,<br> // Username des reporteten Spielers. `null` wenn Spieler unbekannt ist<br> reported: string \| null,<br> // Grund des Reports<br> reason: string<br>}</pre> |
|
||||||
| Ein neuer Strike wurde erstellt | <pre>x-webhook-action: strike</pre> | <pre>{<br> // UUID des Spielers, der gestriked wurde</br> user: string<br>}</pre> |
|
| Ein neuer Strike wurde erstellt | <pre>x-webhook-action: strike</pre> | <pre>{<br> // UUID des Spielers, der gestriked wurde</br> uuid: string<br>}</pre> |
|
||||||
|
|||||||
@@ -120,8 +120,8 @@ export const report = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendWebhook(WebhookAction.Report, {
|
sendWebhook(WebhookAction.Report, {
|
||||||
reporter: report.reporter.username,
|
reporter: report.reporter.uuid,
|
||||||
reported: report.reported?.username ?? null,
|
reported: report.reported?.uuid ?? null,
|
||||||
reason: input.reason
|
reason: input.reason
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -211,7 +211,7 @@ export const report = {
|
|||||||
|
|
||||||
// send webhook in background
|
// send webhook in background
|
||||||
sendWebhook(WebhookAction.Strike, {
|
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),
|
birthday: new Date(input.birthday).toISOString().slice(0, 10),
|
||||||
telephone: input.phone,
|
telephone: input.phone,
|
||||||
username: input.username,
|
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({
|
const postSchema = z.object({
|
||||||
event: z.string(),
|
event: z.string(),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
users: z.array(z.string())
|
uuids: z.array(z.string())
|
||||||
});
|
});
|
||||||
|
|
||||||
export const POST: APIRoute = async ({ request }) => {
|
export const POST: APIRoute = async ({ request }) => {
|
||||||
@@ -25,7 +25,7 @@ export const POST: APIRoute = async ({ request }) => {
|
|||||||
const feedbacks = await db.addUserFeedbacks({
|
const feedbacks = await db.addUserFeedbacks({
|
||||||
event: parsed.event,
|
event: parsed.event,
|
||||||
title: parsed.title,
|
title: parsed.title,
|
||||||
uuids: parsed.users
|
uuids: parsed.uuids
|
||||||
});
|
});
|
||||||
|
|
||||||
const response = feedbacks.map((feedback) => ({
|
const response = feedbacks.map((feedback) => ({
|
||||||
|
|||||||
@@ -3,23 +3,23 @@ import type { APIRoute } from 'astro';
|
|||||||
import { db } from '@db/database.ts';
|
import { db } from '@db/database.ts';
|
||||||
import { checkApiBasicAuth } from '@util/auth.ts';
|
import { checkApiBasicAuth } from '@util/auth.ts';
|
||||||
|
|
||||||
const getSchema = z.object({
|
const postSchema = z.object({
|
||||||
user: z.string()
|
uuid: z.string()
|
||||||
});
|
});
|
||||||
|
|
||||||
export const GET: APIRoute = async ({ request }) => {
|
export const POST: APIRoute = async ({ request }) => {
|
||||||
if (!checkApiBasicAuth(request.headers)) {
|
if (!checkApiBasicAuth(request.headers)) {
|
||||||
return new Response(null, { status: 401 });
|
return new Response(null, { status: 401 });
|
||||||
}
|
}
|
||||||
|
|
||||||
let parsed;
|
let parsed;
|
||||||
try {
|
try {
|
||||||
parsed = await getSchema.parseAsync(await request.json());
|
parsed = await postSchema.parseAsync(await request.json());
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return new Response(null, { status: 400 });
|
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 });
|
if (!user) return new Response(null, { status: 404 });
|
||||||
|
|
||||||
const strikes = await db.getStrikesByUserId({ userId: user.id });
|
const strikes = await db.getStrikesByUserId({ userId: user.id });
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export type WebhookActionType<T extends WebhookAction> = {
|
|||||||
telephone: string | null;
|
telephone: string | null;
|
||||||
username: string;
|
username: string;
|
||||||
edition: 'java' | 'bedrock';
|
edition: 'java' | 'bedrock';
|
||||||
|
uuid: string | null;
|
||||||
};
|
};
|
||||||
[WebhookAction.Report]: {
|
[WebhookAction.Report]: {
|
||||||
reporter: string | null;
|
reporter: string | null;
|
||||||
@@ -23,7 +24,7 @@ export type WebhookActionType<T extends WebhookAction> = {
|
|||||||
reason: string;
|
reason: string;
|
||||||
};
|
};
|
||||||
[WebhookAction.Strike]: {
|
[WebhookAction.Strike]: {
|
||||||
user: string;
|
uuid: string;
|
||||||
};
|
};
|
||||||
}[T];
|
}[T];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user