feat: Enable Conferencing Apps for Team Events [CAL-1925] (#10383)
Co-authored-by: Omar López <[email protected]> Co-authored-by: Hariom Balhara <[email protected]>
This commit is contained in:
30 files changed
+310
-140
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import getApps from "@calcom/app-store/utils";
|
||||
import type { CredentialData } from "@calcom/app-store/utils";
|
||||
import type { CredentialDataWithTeamName } from "@calcom/app-store/utils";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
|
||||
import type { Prisma } from ".prisma/client";
|
||||
@@ -10,7 +10,7 @@ import type { Prisma } from ".prisma/client";
|
||||
* @param filterOnCredentials - Only include apps where credentials are present
|
||||
* @returns A list of enabled app metadata & credentials tied to them
|
||||
*/
|
||||
const getEnabledApps = async (credentials: CredentialData[], filterOnCredentials?: boolean) => {
|
||||
const getEnabledApps = async (credentials: CredentialDataWithTeamName[], filterOnCredentials?: boolean) => {
|
||||
const filterOnIds = {
|
||||
credentials: {
|
||||
some: {
|
||||
@@ -33,7 +33,8 @@ const getEnabledApps = async (credentials: CredentialData[], filterOnCredentials
|
||||
|
||||
const enabledApps = await prisma.app.findMany({
|
||||
where: {
|
||||
OR: [{ enabled: true, ...(filterOnIds.credentials.some.OR.length && filterOnIds) }],
|
||||
enabled: true,
|
||||
...(filterOnIds.credentials.some.OR.length && filterOnIds),
|
||||
},
|
||||
select: { slug: true, enabled: true },
|
||||
});
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import type { PrismaClient } from "@prisma/client";
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
||||
import { getLocationGroupedOptions } from "@calcom/app-store/server";
|
||||
import type { StripeData } from "@calcom/app-store/stripepayment/lib/server";
|
||||
import { getEventTypeAppData, getLocationGroupedOptions } from "@calcom/app-store/utils";
|
||||
import { getEventTypeAppData } from "@calcom/app-store/utils";
|
||||
import type { LocationObject } from "@calcom/core/location";
|
||||
import { getBookingFieldsWithSystemFields } from "@calcom/features/bookings/lib/getBookingFields";
|
||||
import { parseBookingLimit, parseDurationLimit, parseRecurringEvent } from "@calcom/lib";
|
||||
import getEnabledApps from "@calcom/lib/apps/getEnabledApps";
|
||||
import { CAL_URL } from "@calcom/lib/constants";
|
||||
import getPaymentAppData from "@calcom/lib/getPaymentAppData";
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
import { SchedulingType, MembershipRole } from "@calcom/prisma/enums";
|
||||
import { SchedulingType, MembershipRole, AppCategories } from "@calcom/prisma/enums";
|
||||
import { customInputSchema, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
|
||||
|
||||
import { TRPCError } from "@trpc/server";
|
||||
@@ -229,6 +229,9 @@ export default async function getEventTypeById({
|
||||
userId,
|
||||
app: {
|
||||
enabled: true,
|
||||
categories: {
|
||||
hasSome: [AppCategories.conferencing, AppCategories.video],
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
@@ -326,9 +329,20 @@ export default async function getEventTypeById({
|
||||
);
|
||||
|
||||
const currentUser = eventType.users.find((u) => u.id === userId);
|
||||
|
||||
const t = await getTranslation(currentUser?.locale ?? "en", "common");
|
||||
const integrations = await getEnabledApps(credentials, true);
|
||||
const locationOptions = getLocationGroupedOptions(integrations, t);
|
||||
|
||||
if (!currentUser?.id && !eventType.teamId) {
|
||||
throw new TRPCError({
|
||||
code: "NOT_FOUND",
|
||||
message: "Could not find user or team",
|
||||
});
|
||||
}
|
||||
|
||||
const locationOptions = await getLocationGroupedOptions(
|
||||
eventType.teamId ? { teamId: eventType.teamId } : { userId },
|
||||
t
|
||||
);
|
||||
if (eventType.schedulingType === SchedulingType.MANAGED) {
|
||||
locationOptions.splice(0, 0, {
|
||||
label: t("default"),
|
||||
|
||||
Reference in new issue
Block a user