fix: Dynamic events prevent fetching all users that share a username [CAL-2409] (#11288)
* For dynamic search users based on org * Type fix --------- Co-authored-by: alannnc <alannnc@gmail.com> Co-authored-by: Leo Giovanetti <hello@leog.me> Co-authored-by: Peer Richelsen <peeroke@gmail.com>
This commit is contained in:
parent
79b60adf9b
commit
919066222b
|
@ -10,8 +10,7 @@ import {
|
||||||
getMultipleDurationValue,
|
getMultipleDurationValue,
|
||||||
} from "@calcom/features/bookings/lib/get-booking";
|
} from "@calcom/features/bookings/lib/get-booking";
|
||||||
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
||||||
import { getSlugOrRequestedSlug } from "@calcom/features/ee/organizations/lib/orgDomains";
|
import { orgDomainConfig, userOrgQuery } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||||
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
|
||||||
import { getUsernameList } from "@calcom/lib/defaultEvents";
|
import { getUsernameList } from "@calcom/lib/defaultEvents";
|
||||||
import slugify from "@calcom/lib/slugify";
|
import slugify from "@calcom/lib/slugify";
|
||||||
import prisma from "@calcom/prisma";
|
import prisma from "@calcom/prisma";
|
||||||
|
@ -152,7 +151,7 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
username,
|
username,
|
||||||
organization: isValidOrgDomain && currentOrgDomain ? getSlugOrRequestedSlug(currentOrgDomain) : null,
|
organization: userOrgQuery(context.req.headers.host ?? "", context.params?.orgSlug),
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
away: true,
|
away: true,
|
||||||
|
|
|
@ -35,6 +35,7 @@ import {
|
||||||
import { getBookingFieldsWithSystemFields } from "@calcom/features/bookings/lib/getBookingFields";
|
import { getBookingFieldsWithSystemFields } from "@calcom/features/bookings/lib/getBookingFields";
|
||||||
import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";
|
import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";
|
||||||
import { handleWebhookTrigger } from "@calcom/features/bookings/lib/handleWebhookTrigger";
|
import { handleWebhookTrigger } from "@calcom/features/bookings/lib/handleWebhookTrigger";
|
||||||
|
import { userOrgQuery } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||||
import {
|
import {
|
||||||
allowDisablingAttendeeConfirmationEmails,
|
allowDisablingAttendeeConfirmationEmails,
|
||||||
allowDisablingHostConfirmationEmails,
|
allowDisablingHostConfirmationEmails,
|
||||||
|
@ -732,6 +733,7 @@ async function handler(
|
||||||
const users = await prisma.user.findMany({
|
const users = await prisma.user.findMany({
|
||||||
where: {
|
where: {
|
||||||
username: { in: dynamicUserList },
|
username: { in: dynamicUserList },
|
||||||
|
organization: userOrgQuery(req.headers.host ? req.headers.host.replace(/^https?:\/\//, "") : ""),
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
...userSelect.select,
|
...userSelect.select,
|
||||||
|
|
|
@ -64,3 +64,8 @@ export function getSlugOrRequestedSlug(slug: string) {
|
||||||
],
|
],
|
||||||
} satisfies Prisma.TeamWhereInput;
|
} satisfies Prisma.TeamWhereInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function userOrgQuery(hostname: string, fallback?: string | string[]) {
|
||||||
|
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(hostname, fallback);
|
||||||
|
return isValidOrgDomain && currentOrgDomain ? getSlugOrRequestedSlug(currentOrgDomain) : null;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user