feat: more webhook functionality

This commit is contained in:
Catalin Pit
2024-02-14 14:38:58 +02:00
parent 0209127136
commit 61958989b4
8 changed files with 287 additions and 14 deletions

View 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,
},
});
};

View 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,
},
});
};

View 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,
},
});
};