feat: conferencing atoms (#17988)
* added api/v2 for zoom connect * Update conferencing.controller.ts * fix: added api for ConferencingAppsViewPlatformWrapper * type fixes * added getBulkEventTypes api for bulk-update default location * added bulk-update-to-default-location * fix:bulk-update-to-default-location * invalidated * fixed returnTo and onErrorReturnTo * make logos work for conferencing atoms * smalll improvements * fixup * share common types * type fix, and fixed a typo * fix: type-error * fix: json.parse(json.parse()) * fix: invalidate query * fix: removing app throws error in the main app * undo platform-libraries-1.2.3 * update platform-libraries version --------- Co-authored-by: Morgan <[email protected]>
This commit is contained in:
1 parent
44115ac7fa
commit
063400fcbc
54 files changed
+1898
-413
No files matched your search
@@ -0,0 +1,59 @@
|
||||
import type { LocationObject } from "@calcom/app-store/locations";
|
||||
import { getAppFromSlug } from "@calcom/app-store/utils";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
import type { User } from "@calcom/prisma/client";
|
||||
import { userMetadata as userMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
export const bulkUpdateEventsToDefaultLocation = async ({
|
||||
eventTypeIds,
|
||||
user,
|
||||
prisma,
|
||||
}: {
|
||||
eventTypeIds: number[];
|
||||
user: Pick<User, "id" | "metadata">;
|
||||
prisma: PrismaClient;
|
||||
}) => {
|
||||
const defaultApp = userMetadataSchema.parse(user.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: {
|
||||
userId: user.id,
|
||||
appId: foundApp.slug,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
});
|
||||
|
||||
return await prisma.eventType.updateMany({
|
||||
where: {
|
||||
id: {
|
||||
in: eventTypeIds,
|
||||
},
|
||||
userId: user.id,
|
||||
},
|
||||
data: {
|
||||
locations: [
|
||||
{ type: appType, link: defaultApp.appLink, credentialId: credential?.id },
|
||||
] as LocationObject[],
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user