Files
documenso/packages/lib/server-only/webhooks/get-all-webhooks-by-event-trigger.ts
David Nguyen 32a5d33a16 fix: invalid folder queries (#1898)
Currently the majority of folder mutations only work if the user is the
owner of the folder.
2025-07-16 14:37:55 +10:00

31 lines
627 B
TypeScript

import type { WebhookTriggerEvents } from '@prisma/client';
import { prisma } from '@documenso/prisma';
import { buildTeamWhereQuery } from '../../utils/teams';
export type GetAllWebhooksByEventTriggerOptions = {
event: WebhookTriggerEvents;
userId: number;
teamId: number;
};
export const getAllWebhooksByEventTrigger = async ({
event,
userId,
teamId,
}: GetAllWebhooksByEventTriggerOptions) => {
return prisma.webhook.findMany({
where: {
enabled: true,
eventTriggers: {
has: event,
},
team: buildTeamWhereQuery({
teamId,
userId,
}),
},
});
};