* move delegation credential repository to features * mv credential repository to features * update imports * mv * fix * fix * fix * fix * fix * update imports * update imports * update eslint rule * fix * fix * mv getConnectedDestinationCalendars * fix import errors * mv getCalendarsEvents * remove getUsersCredentials * wip * revert eslint rule change for now * fix type checks * fix * format * cleanup * fix * fix * fix * fix * fix tests * migrate getUserAvailability * migrate * fix tests * fix type checks * fix * fix * migrate crmManager * update imports * migrate raqbUtils to appstore * migrate getLuckyUser to features * migrate findTeamMembersMatchingAttributeLogic to appstore * update imports * fix * fix * fix test * fix unit tests * fix * fix * add eslint config
28 lines
930 B
TypeScript
28 lines
930 B
TypeScript
import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential";
|
|
import { withSelectedCalendars } from "@calcom/lib/server/withSelectedCalendars";
|
|
import { availabilityUserSelect } from "@calcom/prisma";
|
|
import { prisma } from "@calcom/prisma";
|
|
import type { Prisma } from "@calcom/prisma/client";
|
|
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
|
|
|
|
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 enrichUserWithDelegationCredentialsIncludeServiceAccountKey({
|
|
user: withSelectedCalendars(user),
|
|
});
|
|
}
|