This commit is contained in:
1 parent
c12ad5cc57
commit
a6005753df
3 files changed
+20
-7
No files matched your search
@@ -260,8 +260,8 @@ Das Webhook wir so oft gesendet, bis der angegebene Webhook Endpoint eine Respon
|
||||
|
||||
Alle Webhooks:
|
||||
|
||||
| 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'<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 Strike wurde erstellt | <pre>x-webhook-action: strike</pre> | <pre>{<br> // UUID des Spielers, der gestriked wurde</br> uuid: string<br>}</pre> |
|
||||
| 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'<br> //UUID des Nutzers. null wenn keine UUID ermittelt werden konnte<br> uuid: string \| null,<br> // IP-Adresse des Besuchers<br> ip: 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> uuid: string<br>}</pre> |
|
||||
+14
-2
@@ -5,6 +5,17 @@ import { getJavaUuid } from '@util/minecraft.ts';
|
||||
import { getSetting, SettingKey } from '@util/settings.ts';
|
||||
import { sendWebhook, WebhookAction } from '@util/webhook.ts';
|
||||
|
||||
function getClientIp(context: { request: Request; clientAddress: string }) {
|
||||
const forwardedFor = context.request.headers.get('x-forwarded-for');
|
||||
|
||||
if (forwardedFor) {
|
||||
const ip = forwardedFor.split(',')[0].trim();
|
||||
if (ip) return ip;
|
||||
}
|
||||
|
||||
return context.clientAddress;
|
||||
}
|
||||
|
||||
export const signup = {
|
||||
signup: defineAction({
|
||||
input: z.object({
|
||||
@@ -20,7 +31,7 @@ export const signup = {
|
||||
edition: z.enum(['java', 'bedrock']),
|
||||
hash: z.string().nullish()
|
||||
}),
|
||||
handler: async (input) => {
|
||||
handler: async (input, context) => {
|
||||
// check if hash given and if so, if it's valid and nobody has already used it
|
||||
if (input.hash) {
|
||||
const directSignup = await db.getDirectSignupByHash({ hash: input.hash });
|
||||
@@ -85,7 +96,8 @@ export const signup = {
|
||||
telephone: input.phone,
|
||||
username: input.username,
|
||||
edition: input.edition,
|
||||
uuid: uuid
|
||||
uuid: uuid,
|
||||
ip: getClientIp(context)
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
@@ -17,6 +17,7 @@ export type WebhookActionType<T extends WebhookAction> = {
|
||||
username: string;
|
||||
edition: 'java' | 'bedrock';
|
||||
uuid: string | null;
|
||||
ip: string;
|
||||
};
|
||||
[WebhookAction.Report]: {
|
||||
reporter: string | null;
|
||||
|
||||
Reference in new issue
Block a user