2023-04-25 22:39:47 +00:00
|
|
|
import { prisma } from "@calcom/prisma";
|
|
|
|
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
|
|
|
|
|
|
|
|
import type { TEditInputSchema } from "./edit.schema";
|
|
|
|
|
|
|
|
type EditOptions = {
|
|
|
|
ctx: {
|
|
|
|
user: NonNullable<TrpcSessionUser>;
|
|
|
|
};
|
|
|
|
input: TEditInputSchema;
|
|
|
|
};
|
|
|
|
|
2023-06-06 11:59:57 +00:00
|
|
|
export const editHandler = async ({ input }: EditOptions) => {
|
2023-04-25 22:39:47 +00:00
|
|
|
const { id, ...data } = input;
|
2023-05-23 01:15:29 +00:00
|
|
|
|
|
|
|
const webhook = await prisma.webhook.findFirst({
|
|
|
|
where: {
|
|
|
|
id,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2023-04-25 22:39:47 +00:00
|
|
|
if (!webhook) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return await prisma.webhook.update({
|
|
|
|
where: {
|
|
|
|
id,
|
|
|
|
},
|
|
|
|
data,
|
|
|
|
});
|
|
|
|
};
|