From 2880a681a8e10e57efb074a16cea1169137520af Mon Sep 17 00:00:00 2001 From: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Date: Wed, 18 Jun 2025 20:06:36 +0530 Subject: [PATCH] feat: disable transcription setting in cal video (#21755) * feat: disable transcription setting in cal video * fix: type err --- .../web/lib/video/[uid]/getServerSideProps.ts | 27 +++++++++++++++ apps/web/modules/videos/ai/ai-transcribe.tsx | 8 ++++- .../videos/views/videos-single-view.tsx | 18 ++++++---- apps/web/public/static/locales/en/common.json | 2 ++ .../eventtypes/components/Locations.tsx | 33 +++++++++++++++++++ packages/features/eventtypes/lib/types.ts | 2 ++ packages/lib/server/repository/booking.ts | 2 ++ .../lib/server/repository/calVideoSettings.ts | 6 ++++ packages/lib/server/repository/eventType.ts | 2 ++ .../event-types/hooks/useEventTypeForm.ts | 2 ++ .../migration.sql | 3 ++ packages/prisma/schema.prisma | 10 +++--- .../server/routers/viewer/eventTypes/types.ts | 2 ++ .../viewer/eventTypes/update.handler.ts | 2 ++ 14 files changed, 108 insertions(+), 11 deletions(-) create mode 100644 packages/prisma/migrations/20250610135051_add_transcription_cal_video_setting/migration.sql diff --git a/apps/web/lib/video/[uid]/getServerSideProps.ts b/apps/web/lib/video/[uid]/getServerSideProps.ts index 7d5f5d4552..17f18a315b 100644 --- a/apps/web/lib/video/[uid]/getServerSideProps.ts +++ b/apps/web/lib/video/[uid]/getServerSideProps.ts @@ -23,6 +23,8 @@ type CalVideoSettings = { disableRecordingForGuests: boolean; disableRecordingForOrganizer: boolean; enableAutomaticTranscription: boolean; + disableTranscriptionForGuests: boolean; + disableTranscriptionForOrganizer: boolean; }; const shouldEnableRecordButton = ({ @@ -57,6 +59,25 @@ const shouldEnableAutomaticTranscription = ({ return !!calVideoSettings.enableAutomaticTranscription; }; +const shouldEnableTranscriptionButton = ({ + hasTeamPlan, + calVideoSettings, + isOrganizer, +}: { + hasTeamPlan: boolean; + calVideoSettings?: CalVideoSettings | null; + isOrganizer: boolean; +}) => { + if (!hasTeamPlan) return false; + if (!calVideoSettings) return true; + + if (isOrganizer) { + return !calVideoSettings.disableTranscriptionForOrganizer; + } + + return !calVideoSettings.disableTranscriptionForGuests; +}; + const checkIfUserIsHost = async ({ booking, sessionUserId, @@ -222,6 +243,11 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { hasTeamPlan: !!hasTeamPlan, calVideoSettings: bookingObj.eventType?.calVideoSettings, }); + const showTranscriptionButton = shouldEnableTranscriptionButton({ + hasTeamPlan: !!hasTeamPlan, + calVideoSettings: bookingObj.eventType?.calVideoSettings, + isOrganizer: sessionUserId === bookingObj.user?.id, + }); return { props: { @@ -245,6 +271,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { loggedInUserName: sessionUserId ? session?.user?.name : undefined, showRecordingButton, enableAutomaticTranscription, + showTranscriptionButton, rediectAttendeeToOnExit: isOrganizer ? undefined : bookingObj.eventType?.calVideoSettings?.redirectUrlOnExit, diff --git a/apps/web/modules/videos/ai/ai-transcribe.tsx b/apps/web/modules/videos/ai/ai-transcribe.tsx index c2576dc9d0..157b1d3ab0 100644 --- a/apps/web/modules/videos/ai/ai-transcribe.tsx +++ b/apps/web/modules/videos/ai/ai-transcribe.tsx @@ -73,9 +73,11 @@ export interface DailyCustomTrayButton { export const CalAiTranscribe = ({ showRecordingButton, enableAutomaticTranscription, + showTranscriptionButton, }: { showRecordingButton: boolean; enableAutomaticTranscription: boolean; + showTranscriptionButton: boolean; }) => { const daily = useDaily(); const { t } = useLocale(); @@ -101,7 +103,11 @@ export const CalAiTranscribe = ({ recording, } : {}), - transcription, + ...(showTranscriptionButton + ? { + transcription, + } + : {}), }); }; diff --git a/apps/web/modules/videos/views/videos-single-view.tsx b/apps/web/modules/videos/views/videos-single-view.tsx index bc3755f65b..5dcf2321c6 100644 --- a/apps/web/modules/videos/views/videos-single-view.tsx +++ b/apps/web/modules/videos/views/videos-single-view.tsx @@ -37,6 +37,7 @@ export default function JoinCall(props: PageProps) { overrideName, showRecordingButton, enableAutomaticTranscription, + showTranscriptionButton, rediectAttendeeToOnExit, } = props; const [daily, setDaily] = useState(null); @@ -80,12 +81,16 @@ export default function JoinCall(props: PageProps) { }, } : {}), - transcription: { - label: "Cal.ai", - tooltip: "Transcription powered by AI", - iconPath: TRANSCRIPTION_STOPPED_ICON, - iconPathDarkMode: TRANSCRIPTION_STOPPED_ICON, - }, + ...(showTranscriptionButton + ? { + transcription: { + label: "Cal.ai", + tooltip: "Transcription powered by AI", + iconPath: TRANSCRIPTION_STOPPED_ICON, + iconPathDarkMode: TRANSCRIPTION_STOPPED_ICON, + }, + } + : {}), }, }), }); @@ -114,6 +119,7 @@ export default function JoinCall(props: PageProps) {
diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index 3bf1001795..a2a087712d 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -49,6 +49,8 @@ "disable_recording_for_guests": "Disable recording for guests", "enable_automatic_transcription": "Enable automatic transcription after joining the meeting", "disable_recording_for_organizer": "Disable recording for organizer", + "disable_transcription_for_guests": "Disable transcription for guests", + "disable_transcription_for_organizer": "Disable transcription for organizer", "event_request_declined_recurring": "Your recurring event request has been declined", "event_request_cancelled": "Your scheduled event was canceled", "event_request_reassigned": "Your scheduled event was reassigned", diff --git a/packages/features/eventtypes/components/Locations.tsx b/packages/features/eventtypes/components/Locations.tsx index e50360648d..21550e3d11 100644 --- a/packages/features/eventtypes/components/Locations.tsx +++ b/packages/features/eventtypes/components/Locations.tsx @@ -388,6 +388,39 @@ const Locations: React.FC = ({ }} /> + {!isPlatform && ( + { + return ( + + ); + }} + /> + )} + {!isPlatform && ( + { + return ( + + ); + }} + /> + )} + { disableRecordingForOrganizer: true, disableRecordingForGuests: true, enableAutomaticTranscription: true, + disableTranscriptionForGuests: true, + disableTranscriptionForOrganizer: true, redirectUrlOnExit: true, }, },