feat: add setting to automatic start recording (#21853)
* feat: disable transcription setting in cal video * feat: add enable automatic recording feature * chore: only when organizer joins * chore: update name of variable * fix: improvements * chore: improvements * chore: add badge * refactor: cal video premium * tests: add tests for cal video * fix: use isOrganizer * Simplify type to remove 'as SessionUser' from new code --------- Co-authored-by: Benny Joo <[email protected]> Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
19 files changed
+857
-197
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
||||
import { generateHashedLink } from "@calcom/lib/generateHashedLink";
|
||||
import { CalVideoSettingsRepository } from "@calcom/lib/server/repository/calVideoSettings";
|
||||
import { EventTypeRepository } from "@calcom/lib/server/repository/eventType";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
|
||||
@@ -44,6 +45,17 @@ export const duplicateHandler = async ({ ctx, input }: DuplicateOptions) => {
|
||||
webhooks: true,
|
||||
hashedLink: true,
|
||||
destinationCalendar: true,
|
||||
calVideoSettings: {
|
||||
select: {
|
||||
disableRecordingForOrganizer: true,
|
||||
disableRecordingForGuests: true,
|
||||
enableAutomaticTranscription: true,
|
||||
enableAutomaticRecordingForOrganizer: true,
|
||||
redirectUrlOnExit: true,
|
||||
disableTranscriptionForGuests: true,
|
||||
disableTranscriptionForOrganizer: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -95,6 +107,7 @@ export const duplicateHandler = async ({ ctx, input }: DuplicateOptions) => {
|
||||
secondaryEmailId,
|
||||
instantMeetingScheduleId: _instantMeetingScheduleId,
|
||||
restrictionScheduleId: _restrictionScheduleId,
|
||||
calVideoSettings,
|
||||
...rest
|
||||
} = eventType;
|
||||
|
||||
@@ -179,6 +192,13 @@ export const duplicateHandler = async ({ ctx, input }: DuplicateOptions) => {
|
||||
});
|
||||
}
|
||||
|
||||
if (calVideoSettings) {
|
||||
await CalVideoSettingsRepository.createCalVideoSettings({
|
||||
eventTypeId: newEventType.id,
|
||||
calVideoSettings,
|
||||
});
|
||||
}
|
||||
|
||||
if (workflows.length > 0) {
|
||||
const relationCreateData = workflows.map((workflow) => {
|
||||
return { eventTypeId: newEventType.id, workflowId: workflow.workflowId };
|
||||
|
||||
@@ -27,12 +27,13 @@ const aiPhoneCallConfig = z
|
||||
|
||||
const calVideoSettingsSchema = z
|
||||
.object({
|
||||
disableRecordingForGuests: z.boolean().optional().nullable(),
|
||||
disableRecordingForOrganizer: z.boolean().optional().nullable(),
|
||||
enableAutomaticTranscription: z.boolean().optional().nullable(),
|
||||
disableTranscriptionForGuests: z.boolean().optional().nullable(),
|
||||
disableTranscriptionForOrganizer: z.boolean().optional().nullable(),
|
||||
redirectUrlOnExit: z.string().url().optional().nullable(),
|
||||
disableRecordingForGuests: z.boolean().nullish(),
|
||||
disableRecordingForOrganizer: z.boolean().nullish(),
|
||||
enableAutomaticTranscription: z.boolean().nullish(),
|
||||
enableAutomaticRecordingForOrganizer: z.boolean().nullish(),
|
||||
disableTranscriptionForGuests: z.boolean().nullish(),
|
||||
disableTranscriptionForOrganizer: z.boolean().nullish(),
|
||||
redirectUrlOnExit: z.string().url().nullish(),
|
||||
})
|
||||
.optional()
|
||||
.nullable();
|
||||
|
||||
@@ -26,6 +26,7 @@ import { TRPCError } from "@trpc/server";
|
||||
|
||||
import type { TrpcSessionUser } from "../../../types";
|
||||
import { setDestinationCalendarHandler } from "../../viewer/calendars/setDestinationCalendar.handler";
|
||||
import { hasTeamPlanHandler } from "../teams/hasTeamPlan.handler";
|
||||
import type { TUpdateInputSchema } from "./update.schema";
|
||||
import {
|
||||
ensureUniqueBookingFields,
|
||||
@@ -130,6 +131,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
disableRecordingForOrganizer: true,
|
||||
disableRecordingForGuests: true,
|
||||
enableAutomaticTranscription: true,
|
||||
enableAutomaticRecordingForOrganizer: true,
|
||||
disableTranscriptionForGuests: true,
|
||||
disableTranscriptionForOrganizer: true,
|
||||
redirectUrlOnExit: true,
|
||||
@@ -598,10 +600,16 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
}
|
||||
|
||||
if (calVideoSettings) {
|
||||
await CalVideoSettingsRepository.createOrUpdateCalVideoSettings({
|
||||
eventTypeId: id,
|
||||
calVideoSettings,
|
||||
const { hasTeamPlan } = await hasTeamPlanHandler({
|
||||
ctx: { user: ctx.user },
|
||||
});
|
||||
|
||||
if (hasTeamPlan) {
|
||||
await CalVideoSettingsRepository.createOrUpdateCalVideoSettings({
|
||||
eventTypeId: id,
|
||||
calVideoSettings,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const parsedEventTypeLocations = eventTypeLocations.safeParse(eventType.locations ?? []);
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
|
||||
|
||||
type HasTeamPlanOptions = {
|
||||
ctx: {
|
||||
user: NonNullable<TrpcSessionUser>;
|
||||
user: { id: number };
|
||||
};
|
||||
};
|
||||
|
||||
export const hasTeamPlanHandler = async ({ ctx }: HasTeamPlanOptions) => {
|
||||
const userId = ctx.user.id;
|
||||
|
||||
export const hasTeamPlanHandler = async ({ ctx: { user } }: HasTeamPlanOptions) => {
|
||||
const hasTeamPlan = await prisma.membership.findFirst({
|
||||
where: {
|
||||
accepted: true,
|
||||
userId,
|
||||
userId: user.id,
|
||||
team: {
|
||||
slug: {
|
||||
not: null,
|
||||
|
||||
Reference in new issue
Block a user