* feat: added zoom, office365-video as valid event-type locations * added docs * Update stripe.service.ts * enable conferencing apps for teams initial commit * fix: make conferencing atom work with teams * update team events in bulk update default location * feat: Separate endpoints for team conferencing apps instead of query params * Display all team events in 'Bulk update existing event types' modal when conferencing atom is enabled for Teams * fix: bulk update default location for team events * removed the organizations endpoints * Refactor: Separate functions for team events to follow SRP * undo extra changes * undo extra changes * fix: platform libraries build breaking * feat: only allow integrations which are installed in create/update team/user event-type endpoints * fix: merge conflicts * remove redundant imports * Update ConferencingAppsViewPlatformWrapper.tsx * Update useBanners.ts * fix: axios error response interceptor * feat: update :app param docs in `organizations-conferencing.controller` * Revert "fix: axios error response interceptor" This reverts commit 729eac3eee9f81c19b5368bbae4b1666884221fd. * Update useAtomsGetInstalledConferencingApps.ts * upgrade platform libraries * Update apps.ts --------- Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Co-authored-by: Morgan Vernay <morgan@cal.com>
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
import type { LocationObject } from "@calcom/app-store/locations";
|
|
import { getAppFromSlug } from "@calcom/app-store/utils";
|
|
import type { PrismaClient } from "@calcom/prisma";
|
|
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
|
|
|
|
import { TRPCError } from "@trpc/server";
|
|
|
|
export const bulkUpdateTeamEventsToDefaultLocation = async ({
|
|
eventTypeIds,
|
|
teamId,
|
|
prisma,
|
|
}: {
|
|
eventTypeIds: number[];
|
|
teamId: number;
|
|
prisma: PrismaClient;
|
|
}) => {
|
|
const team = await prisma.team.findFirst({
|
|
where: { id: teamId },
|
|
select: { metadata: true },
|
|
});
|
|
const defaultApp = teamMetadataSchema.parse(team?.metadata)?.defaultConferencingApp;
|
|
|
|
if (!defaultApp) {
|
|
throw new TRPCError({
|
|
code: "BAD_REQUEST",
|
|
message: "Default conferencing app not set",
|
|
});
|
|
}
|
|
|
|
const foundApp = getAppFromSlug(defaultApp.appSlug);
|
|
const appType = foundApp?.appData?.location?.type;
|
|
if (!appType) {
|
|
throw new TRPCError({
|
|
code: "BAD_REQUEST",
|
|
message: `Default conferencing app '${defaultApp.appSlug}' doesnt exist.`,
|
|
});
|
|
}
|
|
|
|
const credential = await prisma.credential.findFirst({
|
|
where: {
|
|
teamId,
|
|
appId: foundApp.slug,
|
|
},
|
|
select: {
|
|
id: true,
|
|
},
|
|
});
|
|
|
|
return await prisma.eventType.updateMany({
|
|
where: {
|
|
id: {
|
|
in: eventTypeIds,
|
|
},
|
|
teamId,
|
|
},
|
|
data: {
|
|
locations: [
|
|
{ type: appType, link: defaultApp.appLink, credentialId: credential?.id },
|
|
] as LocationObject[],
|
|
},
|
|
});
|
|
};
|