fix: update meeting token if expired (#17096)

This commit is contained in:
Udit Takkar authored and GitHub committed 2024-10-15 10:41:18 -07:00
1 parent a48d190af3
commit 0b914bef79
3 files changed
+55 -3

No files matched your search

@@ -98,6 +98,46 @@ async function processTranscriptsInBatches(transcriptIds: Array<string>) {
return allTranscriptsAccessLinks;
}
export const updateMeetingTokenIfExpired = async ({
bookingReferenceId,
meetingToken,
roomName,
exp,
}: {
bookingReferenceId: number;
meetingToken: string | null;
roomName: string;
exp: number;
}) => {
if (!meetingToken) return null;
try {
await fetcher(`/meeting-tokens/${meetingToken}`).then(ZGetMeetingTokenResponseSchema.parse);
} catch (err) {
const organizerMeetingToken = await postToDailyAPI("/meeting-tokens", {
properties: {
room_name: roomName,
exp: exp,
enable_recording_ui: false,
is_owner: true,
},
}).then(meetingTokenSchema.parse);
await prisma.bookingReference.update({
where: {
id: bookingReferenceId,
},
data: {
meetingPassword: organizerMeetingToken.token,
},
});
return organizerMeetingToken.token;
}
return meetingToken;
};
export const generateGuestMeetingTokenFromOwnerMeetingToken = async (
meetingToken: string | null,
userId?: number
+1 -1
View File
@@ -65,6 +65,6 @@ export const ZGetMeetingTokenResponseSchema = z
room_name: z.string(),
exp: z.number(),
enable_recording_ui: z.boolean().optional(),
user_id: z.number().optional(),
user_id: z.number().nullable().optional(),
})
.passthrough();