2026-09-10 14:23:30 +02:00
|
|
|
import { createFileRoute } from "@tanstack/react-router";
|
|
|
|
|
import { richiediAdmin } from "@/lib/auth-route.server";
|
2026-09-10 14:32:11 +02:00
|
|
|
import { idsConNotificheAttive } from "@/lib/notifiche-attive.server";
|
2026-09-10 14:23:30 +02:00
|
|
|
|
|
|
|
|
export const Route = createFileRoute("/api/public/notifiche-attive")({
|
|
|
|
|
server: {
|
|
|
|
|
handlers: {
|
|
|
|
|
GET: async ({ request }) => {
|
|
|
|
|
const negato = await richiediAdmin(request);
|
|
|
|
|
if (negato) return negato;
|
|
|
|
|
|
|
|
|
|
const { supabaseAdmin } = await import("@/integrations/supabase/client.server");
|
|
|
|
|
const { data, error } = await supabaseAdmin
|
|
|
|
|
.from("push_subscriptions")
|
|
|
|
|
.select("giocatore_id");
|
|
|
|
|
if (error) {
|
|
|
|
|
console.error("notifiche-attive", error);
|
|
|
|
|
return new Response("Errore lettura", { status: 500 });
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 14:32:11 +02:00
|
|
|
return Response.json({ giocatoreIds: idsConNotificheAttive(data ?? []) });
|
2026-09-10 14:23:30 +02:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|