mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
feat: more webhook functionality
This commit is contained in:
21
packages/lib/server-only/webhooks/edit-webhook.ts
Normal file
21
packages/lib/server-only/webhooks/edit-webhook.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import type { Prisma } from '@prisma/client';
|
||||
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
export type EditWebhookOptions = {
|
||||
id: number;
|
||||
data: Prisma.WebhookUpdateInput;
|
||||
userId: number;
|
||||
};
|
||||
|
||||
export const editWebhook = async ({ id, data, userId }: EditWebhookOptions) => {
|
||||
return await prisma.webhook.update({
|
||||
where: {
|
||||
id,
|
||||
userId,
|
||||
},
|
||||
data: {
|
||||
...data,
|
||||
},
|
||||
});
|
||||
};
|
||||
15
packages/lib/server-only/webhooks/get-webhook-by-id.ts
Normal file
15
packages/lib/server-only/webhooks/get-webhook-by-id.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
export type GetWebhookByIdOptions = {
|
||||
id: number;
|
||||
userId: number;
|
||||
};
|
||||
|
||||
export const getWebhookById = async ({ id, userId }: GetWebhookByIdOptions) => {
|
||||
return await prisma.webhook.findFirstOrThrow({
|
||||
where: {
|
||||
id,
|
||||
userId,
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user