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 <[email protected]>
Co-authored-by: Leo Giovanetti <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
authored and GitHub committed 2023-09-26 22:50:10 +01:00
1 parent 79b60adf9b
commit 919066222b
3 files changed
+9 -3

No files matched your search

@@ -35,6 +35,7 @@ import {
import { getBookingFieldsWithSystemFields } from "@calcom/features/bookings/lib/getBookingFields";
import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";
import { handleWebhookTrigger } from "@calcom/features/bookings/lib/handleWebhookTrigger";
import { userOrgQuery } from "@calcom/features/ee/organizations/lib/orgDomains";
import {
allowDisablingAttendeeConfirmationEmails,
allowDisablingHostConfirmationEmails,
@@ -732,6 +733,7 @@ async function handler(
const users = await prisma.user.findMany({
where: {
username: { in: dynamicUserList },
organization: userOrgQuery(req.headers.host ? req.headers.host.replace(/^https?:\/\//, "") : ""),
},
select: {
...userSelect.select,
@@ -64,3 +64,8 @@ export function getSlugOrRequestedSlug(slug: string) {
],
} satisfies Prisma.TeamWhereInput;
}
export function userOrgQuery(hostname: string, fallback?: string | string[]) {
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(hostname, fallback);
return isValidOrgDomain && currentOrgDomain ? getSlugOrRequestedSlug(currentOrgDomain) : null;
}