cal.pub0.org/packages/trpc/server/routers/viewer/apps/checkForGCal.handler.ts

21 lines
431 B
TypeScript

import { prisma } from "@calcom/prisma";
import type { TrpcSessionUser } from "../../../trpc";
type CheckForGCalOptions = {
ctx: {
user: NonNullable<TrpcSessionUser>;
};
};
export const checkForGCalHandler = async ({ ctx }: CheckForGCalOptions) => {
const gCalPresent = await prisma.credential.findFirst({
where: {
type: "google_calendar",
userId: ctx.user.id,
},
});
return !!gCalPresent;
};