Files
calendar/packages/lib/server/findUsersForAvailabilityCheck.ts
T
MorganandGitHub 524c0d81a7 chore: rename DWD to DelegationCredential (#19744)
* Revert "Revert "chore: rename DWD to DelegationCredential (#19703)" (#19734)"

This reverts commit 340b5ab061.

* chore: fix schema and types for now

* fix: domainWideDelegationCredentialId error type
2025-03-05 10:42:20 -03:00

30 lines
885 B
TypeScript

import type { Prisma } from "@prisma/client";
import { enrichUserWithDelegationCredentialsWithoutOrgId } from "@calcom/lib/delegationCredential/server";
import { availabilityUserSelect } from "@calcom/prisma";
import { prisma } from "@calcom/prisma";
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
import { withSelectedCalendars } from "./withSelectedCalendars";
export async function findUsersForAvailabilityCheck({ where }: { where: Prisma.UserWhereInput }) {
const user = await prisma.user.findFirst({
where,
select: {
...availabilityUserSelect,
selectedCalendars: true,
credentials: {
select: credentialForCalendarServiceSelect,
},
},
});
if (!user) {
return null;
}
return await enrichUserWithDelegationCredentialsWithoutOrgId({
user: withSelectedCalendars(user),
});
}