// Dispatcher-only read. Deliberately unguarded and uncached: it runs inside // `after()` where no session or cache scope is guaranteed. Never export this // from the actions barrel. import db from '@admin/db' import { webhookSubscriptions, webhooks } from '@admin/db/schema' import { and, eq } from 'drizzle-orm' export interface ActiveWebhookEndpoint { id: string url: string secret: string } export async function getActiveEndpointsForEvent(event: string): Promise { return db .select({ id: webhooks.id, url: webhooks.url, secret: webhooks.secret }) .from(webhookSubscriptions) .innerJoin(webhooks, eq(webhookSubscriptions.webhookId, webhooks.id)) .where(and(eq(webhookSubscriptions.event, event), eq(webhooks.enabled, true))) }