fix: use meeting id to get transcripts (#16320)
* fix: use meeting id to get transcripts * chore --------- Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
This commit is contained in:
co-authored by
Syed Ali Shahbaz
parent
e362c37ff3
commit
5bc0e1265d
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
Vendored
+2
@@ -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?(
|
||||
|
||||
Reference in New Issue
Block a user