feat: support team webhooks

This commit is contained in:
Mythie
2024-02-27 16:56:32 +11:00
parent 7dd2bbd8ab
commit a4b1f7c983
15 changed files with 505 additions and 29 deletions
@@ -4,15 +4,30 @@ import { prisma } from '@documenso/prisma';
export type EditWebhookOptions = {
id: string;
data: Prisma.WebhookUpdateInput;
data: Omit<Prisma.WebhookUpdateInput, 'id' | 'userId' | 'teamId'>;
userId: number;
teamId?: number;
};
export const editWebhook = async ({ id, data, userId }: EditWebhookOptions) => {
export const editWebhook = async ({ id, data, userId, teamId }: EditWebhookOptions) => {
return await prisma.webhook.update({
where: {
id,
userId,
...(teamId
? {
team: {
id: teamId,
members: {
some: {
userId,
},
},
},
}
: {
userId,
teamId: null,
}),
},
data: {
...data,