perf: Refactor getPublicEvent to fetch org data using DB index key (#21850)
* wip * fix * fix naming * fix typecheck
This commit is contained in:
1 parent
07c8bbc562
commit
a37f1d9798
8 files changed
+79
-51
No files matched your search
@@ -424,7 +424,10 @@ export class EventTypesAtomService {
|
||||
isTeamEvent,
|
||||
orgSlug,
|
||||
this.dbRead.prisma as unknown as PrismaClient,
|
||||
true
|
||||
true,
|
||||
undefined,
|
||||
false,
|
||||
orgId
|
||||
);
|
||||
|
||||
if (!event) {
|
||||
|
||||
@@ -23,7 +23,7 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||
const { link, slug } = paramsSchema.parse(context.params);
|
||||
const { rescheduleUid, duration: queryDuration } = context.query;
|
||||
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req);
|
||||
const org = isValidOrgDomain ? currentOrgDomain : null;
|
||||
const orgSlug = isValidOrgDomain ? currentOrgDomain : null;
|
||||
|
||||
const hashedLink = await prisma.hashedLink.findUnique({
|
||||
where: {
|
||||
@@ -86,7 +86,7 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||
return notFound;
|
||||
}
|
||||
|
||||
if (!org) {
|
||||
if (!orgSlug) {
|
||||
const redirect = await getTemporaryOrgRedirect({
|
||||
slugs: [username],
|
||||
redirectType: RedirectType.User,
|
||||
@@ -103,7 +103,7 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||
|
||||
const [user] = await UserRepository.findUsersByUsername({
|
||||
usernameList: [name],
|
||||
orgSlug: org,
|
||||
orgSlug: orgSlug,
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
@@ -128,8 +128,9 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||
username: name,
|
||||
eventSlug: slug,
|
||||
isTeamEvent,
|
||||
org,
|
||||
orgSlug,
|
||||
fromRedirectOfNonOrgLink: context.query.orgRedirection === "true",
|
||||
orgId: session?.user?.org?.id ?? session?.user?.profile?.organizationId ?? undefined,
|
||||
},
|
||||
session?.user?.id
|
||||
);
|
||||
|
||||
@@ -43,8 +43,8 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
} as const;
|
||||
}
|
||||
|
||||
const org = isValidOrgDomain ? currentOrgDomain : null;
|
||||
if (!org) {
|
||||
const orgSlug = isValidOrgDomain ? currentOrgDomain : null;
|
||||
if (!orgSlug) {
|
||||
return {
|
||||
notFound: true,
|
||||
} as const;
|
||||
@@ -55,8 +55,9 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
username: teamSlug,
|
||||
eventSlug: meetingSlug,
|
||||
isTeamEvent: true,
|
||||
org,
|
||||
orgSlug,
|
||||
fromRedirectOfNonOrgLink: context.query.orgRedirection === "true",
|
||||
orgId: session?.user?.org?.id ?? session?.user?.profile?.organizationId ?? undefined,
|
||||
},
|
||||
session?.user?.id
|
||||
);
|
||||
|
||||
@@ -121,8 +121,8 @@ async function getDynamicGroupPageProps(context: GetServerSidePropsContext) {
|
||||
const { rescheduleUid, bookingUid } = context.query;
|
||||
const allowRescheduleForCancelledBooking = context.query.allowRescheduleForCancelledBooking === "true";
|
||||
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req, context.params?.orgSlug);
|
||||
const org = isValidOrgDomain ? currentOrgDomain : null;
|
||||
if (!org) {
|
||||
const orgSlug = isValidOrgDomain ? currentOrgDomain : null;
|
||||
if (!orgSlug) {
|
||||
const redirect = await getTemporaryOrgRedirect({
|
||||
slugs: usernames,
|
||||
redirectType: RedirectType.User,
|
||||
@@ -155,8 +155,9 @@ async function getDynamicGroupPageProps(context: GetServerSidePropsContext) {
|
||||
{
|
||||
username: usernames.join("+"),
|
||||
eventSlug: slug,
|
||||
org,
|
||||
orgSlug,
|
||||
fromRedirectOfNonOrgLink: context.query.orgRedirection === "true",
|
||||
orgId: session?.user?.org?.id ?? session?.user?.profile?.organizationId ?? undefined,
|
||||
},
|
||||
session?.user?.id
|
||||
);
|
||||
@@ -241,7 +242,7 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||
} as const;
|
||||
}
|
||||
|
||||
const org = isValidOrgDomain ? currentOrgDomain : null;
|
||||
const orgSlug = isValidOrgDomain ? currentOrgDomain : null;
|
||||
|
||||
// We use this to both prefetch the query on the server,
|
||||
// as well as to check if the event exist, so we can show a 404 otherwise.
|
||||
@@ -249,7 +250,7 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||
{
|
||||
username,
|
||||
eventSlug: slug,
|
||||
org,
|
||||
orgSlug,
|
||||
fromRedirectOfNonOrgLink: context.query.orgRedirection === "true",
|
||||
},
|
||||
session?.user?.id
|
||||
@@ -261,7 +262,7 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||
} as const;
|
||||
}
|
||||
|
||||
const allowSEOIndexing = org
|
||||
const allowSEOIndexing = orgSlug
|
||||
? user?.profile?.organization?.organizationSettings?.allowSEOIndexing
|
||||
? user?.allowSEOIndexing
|
||||
: false
|
||||
|
||||
Reference in new issue
Block a user