Skip to content

Scheduling infrastructure for absolutely everyone.

fix: private link for a team event gives 404 (#14473)

Amit Sharma68c4ad2bf9be
diff --git a/apps/web/lib/d/[link]/[slug]/getServerSideProps.tsx b/apps/web/lib/d/[link]/[slug]/getServerSideProps.tsx
index 436f39f4152..f0ab9cb03e5 100644
--- a/apps/web/lib/d/[link]/[slug]/getServerSideProps.tsx
+++ b/apps/web/lib/d/[link]/[slug]/getServerSideProps.tsx
@@ -42,6 +42,8 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
team: {
select: {
id: true,
+ slug: true,
+ hideBranding: true,
},
},
},
@@ -49,36 +51,53 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
},
});
- const username = hashedLink?.eventType.users[0]?.username;
+ let name: string;
+ let isAway = false;
+ let hideBranding = false;
const notFound = {
notFound: true,
} as const;
- if (!hashedLink || !username) {
+ if (!hashedLink) {
return notFound;
}
- if (!org) {
- const redirect = await getTemporaryOrgRedirect({
- slugs: [username],
- redirectType: RedirectType.User,
- eventTypeSlug: slug,
- currentQuery: context.query,
- });
+ if (hashedLink.eventType.team) {
+ name = hashedLink.eventType.team.slug || "";
+ hideBranding = hashedLink.eventType.team.hideBranding;
+ } else {
+ const username = hashedLink.eventType.users[0]?.username;
- if (redirect) {
- return redirect;
+ if (!username) {
+ return notFound;
}
- }
- const [user] = await UserRepository.findUsersByUsername({
- usernameList: [username],
- orgSlug: org,
- });
+ if (!org) {
+ const redirect = await getTemporaryOrgRedirect({
+ slugs: [username],
+ redirectType: RedirectType.User,
+ eventTypeSlug: slug,
+ currentQuery: context.query,
+ });
+
+ if (redirect) {
+ return redirect;
+ }
+ }
- if (!user) {
- return notFound;
+ const [user] = await UserRepository.findUsersByUsername({
+ usernameList: [username],
+ orgSlug: org,
+ });
+
+ if (!user) {
+ return notFound;
+ }
+
+ name = username;
+ isAway = user.away;
+ hideBranding = user.hideBranding;
}
let booking: GetBookingType | null = null;
@@ -90,7 +109,12 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
// We use this to both prefetch the query on the server,
// as well as to check if the event exist, so we c an show a 404 otherwise.
- const eventData = await ssr.viewer.public.event.fetch({ username, eventSlug: slug, isTeamEvent, org });
+ const eventData = await ssr.viewer.public.event.fetch({
+ username: name,
+ eventSlug: slug,
+ isTeamEvent,
+ org,
+ });
if (!eventData) {
return notFound;
@@ -105,11 +129,11 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
eventData.length
),
booking,
- away: user?.away,
- user: username,
+ away: isAway,
+ user: name,
slug,
trpcState: ssr.dehydrate(),
- isBrandingHidden: user?.hideBranding,
+ isBrandingHidden: hideBranding,
// Sending the team event from the server, because this template file
// is reused for both team and user events.
isTeamEvent,