Skip to content

Scheduling infrastructure for absolutely everyone.

fix: use meeting id to get transcripts (#16320)

Udit Takkar5bc0e1265ddb
diff --git a/apps/web/pages/api/recorded-daily-video.ts b/apps/web/pages/api/recorded-daily-video.ts
index ceab1c5ffcb..54e8d5adf65 100644
--- a/apps/web/pages/api/recorded-daily-video.ts
+++ b/apps/web/pages/api/recorded-daily-video.ts
@@ -6,7 +6,7 @@ import {
getDownloadLinkOfCalVideoByRecordingId,
submitBatchProcessorTranscriptionJob,
} from "@calcom/core/videoClient";
-import { getAllTranscriptsAccessLinkFromRoomName } from "@calcom/core/videoClient";
+import { getAllTranscriptsAccessLinkFromMeetingId } from "@calcom/core/videoClient";
import { sendDailyVideoRecordingEmails } from "@calcom/emails";
import { sendDailyVideoTranscriptEmails } from "@calcom/emails";
import { getTeamIdFromEventType } from "@calcom/lib/getTeamIdFromEventType";
@@ -153,15 +153,17 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
});
}
- const { room } = meetingEndedResponse.data.payload;
+ const { room, meeting_id } = meetingEndedResponse.data.payload;
const bookingReference = await getBookingReference(room);
const booking = await getBooking(bookingReference.bookingId as number);
- const transcripts = await getAllTranscriptsAccessLinkFromRoomName(room);
+ const transcripts = await getAllTranscriptsAccessLinkFromMeetingId(meeting_id);
if (!transcripts || !transcripts.length)
- return res.status(200).json({ message: `No Transcripts found for room name ${room}` });
+ return res
+ .status(200)
+ .json({ message: `No Transcripts found for room name ${room} and meeting id ${meeting_id}` });
const evt = await getCalendarEvent(booking);
await sendDailyVideoTranscriptEmails(evt, transcripts);
diff --git a/packages/app-store/dailyvideo/lib/VideoApiAdapter.ts b/packages/app-store/dailyvideo/lib/VideoApiAdapter.ts
index f9b3cef1df6..05ea6422479 100644
--- a/packages/app-store/dailyvideo/lib/VideoApiAdapter.ts
+++ b/packages/app-store/dailyvideo/lib/VideoApiAdapter.ts
@@ -314,6 +314,24 @@ const DailyVideoApiAdapter = (): VideoApiAdapter => {
throw new Error("Something went wrong! Unable to get transcription access link");
}
},
+ getAllTranscriptsAccessLinkFromMeetingId: async (meetingId: string): Promise<Array<string>> => {
+ try {
+ const allTranscripts = await fetcher(`/transcript?mtgSessionId=${meetingId}`).then(
+ getTranscripts.parse
+ );
+
+ if (!allTranscripts.data.length) return [];
+
+ const allTranscriptsIds = allTranscripts.data.map((transcript) => transcript.transcriptId);
+ const allTranscriptsAccessLink = await processTranscriptsInBatches(allTranscriptsIds);
+ const accessLinks = await Promise.all(allTranscriptsAccessLink);
+
+ return Promise.resolve(accessLinks);
+ } catch (err) {
+ console.log("err", err);
+ throw new Error("Something went wrong! Unable to get transcription access link");
+ }
+ },
submitBatchProcessorJob: async (body: batchProcessorBody): Promise<TSubmitBatchProcessorJobRes> => {
try {
const batchProcessorJob = await postToDailyAPI("/batch-processor", body).then(
diff --git a/packages/core/videoClient.ts b/packages/core/videoClient.ts
index 8cfba66aee7..acb7aeecfce 100644
--- a/packages/core/videoClient.ts
+++ b/packages/core/videoClient.ts
@@ -301,6 +301,29 @@ const getAllTranscriptsAccessLinkFromRoomName = async (roomName: string) => {
return videoAdapter?.getAllTranscriptsAccessLinkFromRoomName?.(roomName);
};
+const getAllTranscriptsAccessLinkFromMeetingId = async (meetingId: string) => {
+ let dailyAppKeys: Awaited<ReturnType<typeof getDailyAppKeys>>;
+ try {
+ dailyAppKeys = await getDailyAppKeys();
+ } catch (e) {
+ console.error("Error: Cal video provider is not installed.");
+ return;
+ }
+ const [videoAdapter] = await getVideoAdapters([
+ {
+ id: 0,
+ appId: "daily-video",
+ type: "daily_video",
+ userId: null,
+ user: { email: "" },
+ teamId: null,
+ key: dailyAppKeys,
+ invalid: false,
+ },
+ ]);
+ return videoAdapter?.getAllTranscriptsAccessLinkFromMeetingId?.(meetingId);
+};
+
const submitBatchProcessorTranscriptionJob = async (recordingId: string) => {
let dailyAppKeys: Awaited<ReturnType<typeof getDailyAppKeys>>;
try {
@@ -392,6 +415,7 @@ export {
getRecordingsOfCalVideoByRoomName,
getDownloadLinkOfCalVideoByRecordingId,
getAllTranscriptsAccessLinkFromRoomName,
+ getAllTranscriptsAccessLinkFromMeetingId,
submitBatchProcessorTranscriptionJob,
getTranscriptsAccessLinkFromRecordingId,
checkIfRoomNameMatchesInRecording,
diff --git a/packages/types/VideoApiAdapter.d.ts b/packages/types/VideoApiAdapter.d.ts
index 136a4fdf9d3..96331d2ccfd 100644
--- a/packages/types/VideoApiAdapter.d.ts
+++ b/packages/types/VideoApiAdapter.d.ts
@@ -34,6 +34,8 @@ export type VideoApiAdapter =
getAllTranscriptsAccessLinkFromRoomName?(roomName: string): Promise<Array<string>>;
+ getAllTranscriptsAccessLinkFromMeetingId?(meetingId: string): Promise<Array<string>>;
+
submitBatchProcessorJob?(body: batchProcessorBody): Promise<TSubmitBatchProcessorJobRes>;
getTranscriptsAccessLinkFromRecordingId?(