Scheduling infrastructure for absolutely everyone.
chore: Removing away (DB related, not slot related) from code (#14673)
Alex van Andela15cad4d03fc
diff --git a/apps/api/v1/lib/validations/user.ts b/apps/api/v1/lib/validations/user.tsindex 2bccf2f961d..cf237f8045b 100644--- a/apps/api/v1/lib/validations/user.ts+++ b/apps/api/v1/lib/validations/user.ts@@ -82,7 +82,6 @@ export const schemaUserBaseBodyParams = User.pick({brandColor: true,darkBrandColor: true,allowDynamicBooking: true,- away: true,role: true,// @note: disallowing avatar changes via API for now. We can add it later if needed. User should upload image via UI.// avatar: true,@@ -171,7 +170,6 @@ export const schemaUserReadPublic = User.pick({brandColor: true,darkBrandColor: true,allowDynamicBooking: true,- away: true,createdDate: true,verified: true,invitedTo: true,diff --git a/apps/web/lib/d/[link]/[slug]/getServerSideProps.tsx b/apps/web/lib/d/[link]/[slug]/getServerSideProps.tsxindex f0ab9cb03e5..7811be9ea23 100644--- a/apps/web/lib/d/[link]/[slug]/getServerSideProps.tsx+++ b/apps/web/lib/d/[link]/[slug]/getServerSideProps.tsx@@ -52,7 +52,6 @@ async function getUserPageProps(context: GetServerSidePropsContext) {});let name: string;- let isAway = false;let hideBranding = false;const notFound = {@@ -96,7 +95,6 @@ async function getUserPageProps(context: GetServerSidePropsContext) {}name = username;- isAway = user.away;hideBranding = user.hideBranding;}@@ -129,7 +127,6 @@ async function getUserPageProps(context: GetServerSidePropsContext) {eventData.length),booking,- away: isAway,user: name,slug,trpcState: ssr.dehydrate(),diff --git a/apps/web/lib/team/[slug]/[type]/getServerSideProps.tsx b/apps/web/lib/team/[slug]/[type]/getServerSideProps.tsxindex f5263dfa452..03a7c876965 100644--- a/apps/web/lib/team/[slug]/[type]/getServerSideProps.tsx+++ b/apps/web/lib/team/[slug]/[type]/getServerSideProps.tsx@@ -89,7 +89,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>metadata: eventData.metadata,},booking,- away: false,user: teamSlug,teamId: team.id,slug: meetingSlug,diff --git a/apps/web/modules/users/views/users-public-view.getServerSideProps.tsx b/apps/web/modules/users/views/users-public-view.getServerSideProps.tsxindex 95d820689b7..ffa51aeb7cb 100644--- a/apps/web/modules/users/views/users-public-view.getServerSideProps.tsx+++ b/apps/web/modules/users/views/users-public-view.getServerSideProps.tsx@@ -39,7 +39,7 @@ export type UserPageProps = {allowSEOIndexing: boolean;username: string | null;};- users: (Pick<User, "away" | "name" | "username" | "bio" | "verified" | "avatarUrl"> & {+ users: (Pick<User, "name" | "username" | "bio" | "verified" | "avatarUrl"> & {profile: UserProfile;})[];themeBasis: string | null;@@ -177,7 +177,6 @@ export const getServerSideProps: GetServerSideProps<UserPageProps> = async (contavatarUrl: user.avatarUrl,verified: user.verified,profile: user.profile,- away: user.away,})),entity: {...(org?.logoUrl ? { logoUrl: org?.logoUrl } : {}),diff --git a/apps/web/modules/users/views/users-type-public-view.getServerSideProps.tsx b/apps/web/modules/users/views/users-type-public-view.getServerSideProps.tsxindex 13bfa996c61..42a03703f77 100644--- a/apps/web/modules/users/views/users-type-public-view.getServerSideProps.tsx+++ b/apps/web/modules/users/views/users-type-public-view.getServerSideProps.tsx@@ -86,7 +86,6 @@ async function getDynamicGroupPageProps(context: GetServerSidePropsContext) {booking,user: usernames.join("+"),slug,- away: false,trpcState: ssr.dehydrate(),isBrandingHidden: false,isSEOIndexable: true,@@ -165,7 +164,6 @@ async function getUserPageProps(context: GetServerSidePropsContext) {},user: username,slug,- away: false,trpcState: ssr.dehydrate(),isBrandingHidden: user?.hideBranding,isSEOIndexable: user?.allowSEOIndexing,diff --git a/apps/web/modules/users/views/users-type-public-view.tsx b/apps/web/modules/users/views/users-type-public-view.tsxindex f0d4e9650ee..5986861538a 100644--- a/apps/web/modules/users/views/users-type-public-view.tsx+++ b/apps/web/modules/users/views/users-type-public-view.tsx@@ -23,7 +23,6 @@ export default function Type({user,isEmbed,booking,- away,isBrandingHidden,isSEOIndexable,rescheduleUid,@@ -47,7 +46,6 @@ export default function Type({username={user}eventSlug={slug}bookingData={booking}- isAway={away}hideBranding={isBrandingHidden}entity={eventData.entity}durationConfig={eventData.metadata?.multipleDuration}diff --git a/apps/web/pages/d/[link]/[slug].tsx b/apps/web/pages/d/[link]/[slug].tsxindex f6fc4e9aa1b..20233baca17 100644--- a/apps/web/pages/d/[link]/[slug].tsx+++ b/apps/web/pages/d/[link]/[slug].tsx@@ -13,7 +13,6 @@ export default function Type({isEmbed,user,booking,- away,isBrandingHidden,isTeamEvent,entity,@@ -33,7 +32,6 @@ export default function Type({username={user}eventSlug={slug}bookingData={booking}- isAway={away}hideBranding={isBrandingHidden}isTeamEvent={isTeamEvent}entity={entity}diff --git a/apps/web/pages/org/[orgSlug]/instant-meeting/team/[slug]/[type].tsx b/apps/web/pages/org/[orgSlug]/instant-meeting/team/[slug]/[type].tsxindex 85bff0b1da1..158202b9134 100644--- a/apps/web/pages/org/[orgSlug]/instant-meeting/team/[slug]/[type].tsx+++ b/apps/web/pages/org/[orgSlug]/instant-meeting/team/[slug]/[type].tsx@@ -21,7 +21,6 @@ export default function Type({slug,user,booking,- away,isEmbed,isBrandingHidden,entity,@@ -42,7 +41,6 @@ export default function Type({username={user}eventSlug={slug}bookingData={booking}- isAway={away}hideBranding={isBrandingHidden}isTeamEventisInstantMeeting@@ -110,7 +108,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>eventData.length),booking: null,- away: false,user: teamSlug,teamId: team.id,slug: meetingSlug,diff --git a/apps/web/pages/team/[slug]/[type].tsx b/apps/web/pages/team/[slug]/[type].tsxindex 112db061747..3f6eda1ca30 100644--- a/apps/web/pages/team/[slug]/[type].tsx+++ b/apps/web/pages/team/[slug]/[type].tsx@@ -30,7 +30,6 @@ export default function Type({slug,user,booking,- away,isEmbed,isBrandingHidden,eventData,@@ -54,7 +53,6 @@ export default function Type({username={user}eventSlug={slug}bookingData={booking}- isAway={away}isInstantMeeting={isInstantMeeting}hideBranding={isBrandingHidden}isTeamEventdiff --git a/apps/web/test/utils/bookingScenario/getSampleUserInSession.ts b/apps/web/test/utils/bookingScenario/getSampleUserInSession.tsindex 5057c206d20..56b472ad4f1 100644--- a/apps/web/test/utils/bookingScenario/getSampleUserInSession.ts+++ b/apps/web/test/utils/bookingScenario/getSampleUserInSession.ts@@ -31,7 +31,6 @@ export const getSampleUserInSession = function () {identityProvider: IdentityProvider.CAL,brandColor: "#292929",darkBrandColor: "#fafafa",- away: false,metadata: null,role: UserPermissionRole.USER,disableImpersonation: false,diff --git a/packages/features/bookings/Booker/types.ts b/packages/features/bookings/Booker/types.tsindex cb38256aaec..01e899424f5 100644--- a/packages/features/bookings/Booker/types.ts+++ b/packages/features/bookings/Booker/types.ts@@ -51,11 +51,6 @@ export interface BookerProps {selectedDate?: Date;hideBranding?: boolean;- /**- * Sets the Booker component to the away state.- * This is NOT revalidated by calling the API.- */- isAway?: boolean;/*** If false and the current username indicates a dynamic booking,* the Booker will immediately show an error.diff --git a/packages/features/ee/users/server/trpc-router.ts b/packages/features/ee/users/server/trpc-router.tsindex 7d62928ec23..4647604bca9 100644--- a/packages/features/ee/users/server/trpc-router.ts+++ b/packages/features/ee/users/server/trpc-router.ts@@ -28,7 +28,6 @@ const userBodySchema = User.pick({// darkBrandColor: true,allowDynamicBooking: true,identityProvider: true,- // away: true,role: true,avatarUrl: true,});diff --git a/packages/features/shell/Shell.tsx b/packages/features/shell/Shell.tsxindex 3c660d2015b..59bd05bcf99 100644--- a/packages/features/shell/Shell.tsx+++ b/packages/features/shell/Shell.tsx@@ -397,29 +397,7 @@ function UserDropdown({ small }: UserDropdownProps) {screenResolution: `${screen.width}x${screen.height}`,});});- const mutation = trpc.viewer.away.useMutation({- onMutate: async ({ away }) => {- await utils.viewer.me.cancel();- const previousValue = utils.viewer.me.getData();-- if (previousValue) {- utils.viewer.me.setData(undefined, { ...previousValue, away });- }-- return { previousValue };- },- onError: (_, __, context) => {- if (context?.previousValue) {- utils.viewer.me.setData(undefined, context.previousValue);- }-- showToast(t("toggle_away_error"), "error");- },- onSettled() {- utils.viewer.me.invalidate();- },- });const [helpOpen, setHelpOpen] = useState(false);const [menuOpen, setMenuOpen] = useState(false);diff --git a/packages/lib/server/repository/user.ts b/packages/lib/server/repository/user.tsindex d51b78140ab..c20a12875a4 100644--- a/packages/lib/server/repository/user.ts+++ b/packages/lib/server/repository/user.ts@@ -50,7 +50,6 @@ const userSelect = Prisma.validator<Prisma.UserSelect>()({invitedTo: true,brandColor: true,darkBrandColor: true,- away: true,allowDynamicBooking: true,allowSEOIndexing: true,receiveMonthlyDigestEmail: true,diff --git a/packages/lib/test/builder.ts b/packages/lib/test/builder.tsindex fea2cfb43ce..118f069a908 100644--- a/packages/lib/test/builder.ts+++ b/packages/lib/test/builder.ts@@ -207,7 +207,6 @@ type UserPayload = Prisma.UserGetPayload<{selectedCalendars: true;schedules: true;avatarUrl: true;- away: true;backupCodes: true;bio: true;brandColor: true;@@ -255,7 +254,6 @@ export const buildUser = <T extends Partial<UserPayload>>(allowDynamicBooking: true,availability: [],avatarUrl: "",- away: false,backupCodes: null,bio: null,brandColor: "#292929",diff --git a/packages/trpc/server/middlewares/sessionMiddleware.ts b/packages/trpc/server/middlewares/sessionMiddleware.tsindex 6cfcf1b959e..bd41f2baab3 100644--- a/packages/trpc/server/middlewares/sessionMiddleware.ts+++ b/packages/trpc/server/middlewares/sessionMiddleware.ts@@ -54,7 +54,6 @@ export async function getUserFromSession(ctx: TRPCContextInner, session: Maybe<SidentityProviderId: true,brandColor: true,darkBrandColor: true,- away: true,movedToProfileId: true,selectedCalendars: {select: {diff --git a/packages/trpc/server/routers/loggedInViewer/_router.tsx b/packages/trpc/server/routers/loggedInViewer/_router.tsxindex 1b6066990b4..6440061ef0d 100644--- a/packages/trpc/server/routers/loggedInViewer/_router.tsx+++ b/packages/trpc/server/routers/loggedInViewer/_router.tsx@@ -3,7 +3,6 @@ import { router } from "../../trpc";import { ZAddSecondaryEmailInputSchema } from "./addSecondaryEmail.schema";import { ZAppByIdInputSchema } from "./appById.schema";import { ZAppCredentialsByTypeInputSchema } from "./appCredentialsByType.schema";-import { ZAwayInputSchema } from "./away.schema";import { ZConnectAndJoinInputSchema } from "./connectAndJoin.schema";import { ZConnectedCalendarsInputSchema } from "./connectedCalendars.schema";import { ZDeleteCredentialInputSchema } from "./deleteCredential.schema";@@ -28,7 +27,6 @@ type AppsRouterHandlerCache = {shouldVerifyEmail?: typeof import("./shouldVerifyEmail.handler").shouldVerifyEmailHandler;deleteMe?: typeof import("./deleteMe.handler").deleteMeHandler;deleteMeWithoutPassword?: typeof import("./deleteMeWithoutPassword.handler").deleteMeWithoutPasswordHandler;- away?: typeof import("./away.handler").awayHandler;connectedCalendars?: typeof import("./connectedCalendars.handler").connectedCalendarsHandler;setDestinationCalendar?: typeof import("./setDestinationCalendar.handler").setDestinationCalendarHandler;integrations?: typeof import("./integrations.handler").integrationsHandler;@@ -91,19 +89,6 @@ export const loggedInViewerRouter = router({return UNSTABLE_HANDLER_CACHE.deleteMeWithoutPassword({ ctx });}),- away: authedProcedure.input(ZAwayInputSchema).mutation(async ({ ctx, input }) => {- if (!UNSTABLE_HANDLER_CACHE.away) {- UNSTABLE_HANDLER_CACHE.away = (await import("./away.handler")).awayHandler;- }-- // Unreachable code but required for type safety- if (!UNSTABLE_HANDLER_CACHE.away) {- throw new Error("Failed to load handler");- }-- return UNSTABLE_HANDLER_CACHE.away({ ctx, input });- }),-connectedCalendars: authedProcedure.input(ZConnectedCalendarsInputSchema).query(async ({ ctx, input }) => {if (!UNSTABLE_HANDLER_CACHE.connectedCalendars) {UNSTABLE_HANDLER_CACHE.connectedCalendars = (diff --git a/packages/trpc/server/routers/loggedInViewer/away.handler.ts b/packages/trpc/server/routers/loggedInViewer/away.handler.tsdeleted file mode 100644index b9787cedf58..00000000000--- a/packages/trpc/server/routers/loggedInViewer/away.handler.ts+++ /dev/null@@ -1,22 +0,0 @@-import { prisma } from "@calcom/prisma";-import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";--import type { TAwayInputSchema } from "./away.schema";--type AwayOptions = {- ctx: {- user: NonNullable<TrpcSessionUser>;- };- input: TAwayInputSchema;-};--export const awayHandler = async ({ ctx, input }: AwayOptions) => {- await prisma.user.update({- where: {- email: ctx.user.email,- },- data: {- away: input.away,- },- });-};diff --git a/packages/trpc/server/routers/loggedInViewer/away.schema.ts b/packages/trpc/server/routers/loggedInViewer/away.schema.tsdeleted file mode 100644index da846603326..00000000000--- a/packages/trpc/server/routers/loggedInViewer/away.schema.ts+++ /dev/null@@ -1,7 +0,0 @@-import { z } from "zod";--export const ZAwayInputSchema = z.object({- away: z.boolean(),-});--export type TAwayInputSchema = z.infer<typeof ZAwayInputSchema>;diff --git a/packages/trpc/server/routers/loggedInViewer/me.handler.ts b/packages/trpc/server/routers/loggedInViewer/me.handler.tsindex 9759eaa45f7..b7215107d1c 100644--- a/packages/trpc/server/routers/loggedInViewer/me.handler.ts+++ b/packages/trpc/server/routers/loggedInViewer/me.handler.ts@@ -97,7 +97,6 @@ export const meHandler = async ({ ctx, input }: MeOptions) => {identityProviderEmail,brandColor: user.brandColor,darkBrandColor: user.darkBrandColor,- away: user.away,bio: user.bio,weekStart: user.weekStart,theme: user.theme,