mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
37 lines
737 B
TypeScript
37 lines
737 B
TypeScript
import type { Prisma } from '@prisma/client';
|
|
|
|
import { prisma } from '@documenso/prisma';
|
|
|
|
export type EditWebhookOptions = {
|
|
id: string;
|
|
data: Omit<Prisma.WebhookUpdateInput, 'id' | 'userId' | 'teamId'>;
|
|
userId: number;
|
|
teamId?: number;
|
|
};
|
|
|
|
export const editWebhook = async ({ id, data, userId, teamId }: EditWebhookOptions) => {
|
|
return await prisma.webhook.update({
|
|
where: {
|
|
id,
|
|
...(teamId
|
|
? {
|
|
team: {
|
|
id: teamId,
|
|
members: {
|
|
some: {
|
|
userId,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
: {
|
|
userId,
|
|
teamId: null,
|
|
}),
|
|
},
|
|
data: {
|
|
...data,
|
|
},
|
|
});
|
|
};
|