mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
feat: more webhook functionality
This commit is contained in:
17
packages/lib/server-only/user/get-user-webhooks.ts
Normal file
17
packages/lib/server-only/user/get-user-webhooks.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
export interface GetUserWebhooksByIdOptions {
|
||||
id: number;
|
||||
}
|
||||
|
||||
export const getUserWebhooksById = async ({ id }: GetUserWebhooksByIdOptions) => {
|
||||
return await prisma.user.findFirstOrThrow({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
select: {
|
||||
email: true,
|
||||
Webhooks: true,
|
||||
},
|
||||
});
|
||||
};
|
||||
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