* chore: Remove all code related to the old cache system * Removed some redundant tests, some type fixes * Further type fixes * More type fixes re. tests * Next iteration, couple of fixes remaining * Remove cache from CredentialActionsDropdown * Fix tests by mocking credential, instead of db queries * Remove Cache DI wiring from v2 * Make sure apiv2 build passes * Remove another cache cron * Remove old tokens for calendar-cache v1
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { getConnectedDestinationCalendarsAndEnsureDefaultsInDb } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars";
|
|
import { prisma } from "@calcom/prisma";
|
|
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
|
|
|
|
import type { TConnectedCalendarsInputSchema } from "./connectedCalendars.schema";
|
|
|
|
type ConnectedCalendarsOptions = {
|
|
ctx: {
|
|
user: NonNullable<TrpcSessionUser>;
|
|
};
|
|
input: TConnectedCalendarsInputSchema;
|
|
};
|
|
|
|
export const connectedCalendarsHandler = async ({ ctx, input }: ConnectedCalendarsOptions) => {
|
|
const { user } = ctx;
|
|
const onboarding = input?.onboarding || false;
|
|
|
|
const { connectedCalendars, destinationCalendar } =
|
|
await getConnectedDestinationCalendarsAndEnsureDefaultsInDb({
|
|
user,
|
|
onboarding,
|
|
eventTypeId: input?.eventTypeId ?? null,
|
|
prisma,
|
|
});
|
|
|
|
const enrichedConnectedCalendars = connectedCalendars.map((calendar) => ({
|
|
...calendar,
|
|
cacheUpdatedAt: null,
|
|
}));
|
|
|
|
return {
|
|
connectedCalendars: enrichedConnectedCalendars,
|
|
destinationCalendar,
|
|
};
|
|
};
|