Files
sign/packages/lib/server-only/webhooks/edit-webhook.ts

37 lines
737 B
TypeScript
Raw Normal View History

2024-02-14 14:38:58 +02:00
import type { Prisma } from '@prisma/client';
import { prisma } from '@documenso/prisma';
export type EditWebhookOptions = {
2024-02-27 12:13:56 +11:00
id: string;
2024-02-27 16:56:32 +11:00
data: Omit<Prisma.WebhookUpdateInput, 'id' | 'userId' | 'teamId'>;
2024-02-14 14:38:58 +02:00
userId: number;
2024-02-27 16:56:32 +11:00
teamId?: number;
2024-02-14 14:38:58 +02:00
};
2024-02-27 16:56:32 +11:00
export const editWebhook = async ({ id, data, userId, teamId }: EditWebhookOptions) => {
2024-02-14 14:38:58 +02:00
return await prisma.webhook.update({
where: {
id,
2024-02-27 16:56:32 +11:00
...(teamId
? {
team: {
id: teamId,
members: {
some: {
userId,
},
},
},
}
: {
userId,
teamId: null,
}),
2024-02-14 14:38:58 +02:00
},
data: {
...data,
},
});
};