send webhook on finished api report
All checks were successful
deploy / build-and-deploy (/testvaro, /opt/website-test, website-test) (push) Successful in 25s
deploy / build-and-deploy (/varo, /opt/website, website) (push) Successful in 14s

This commit is contained in:
2025-06-22 13:53:28 +02:00
parent d7b05deff2
commit 1a81b5fb06

View File

@ -2,6 +2,7 @@ import type { APIRoute } from 'astro';
import { z } from 'astro:schema';
import { API_SECRET } from 'astro:env/server';
import { db } from '@db/database.ts';
import { sendWebhook, WebhookAction } from '@util/webhook.ts';
const postSchema = z.object({
reporter: z.string(),
@ -92,5 +93,14 @@ export const PUT: APIRoute = async ({ request }) => {
});
});
const strikes = await db.getStrikesByTeamId({ teamId: reportedTeam.team.id });
const teamMembers = await db.getTeamMembersByTeamId({ teamId: reportedTeam.team.id });
// send webhook in background
sendWebhook(WebhookAction.Strike, {
users: teamMembers.map((tm) => tm.user.uuid!),
totalWeight: strikes.map((strike) => strike.reason.weight).reduce((a, b) => a + b, 0)
});
return new Response(null, { status: 200 });
};