Scheduling infrastructure for absolutely everyone.
fix: cal video recording email (#12079)
Udit Takkar4d49fb0636cd
diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsxindex f600c6e6973..32bb2ca515e 100644--- a/apps/web/components/booking/BookingListItem.tsx+++ b/apps/web/components/booking/BookingListItem.tsx@@ -141,17 +141,6 @@ function BookingListItem(booking: BookingItemProps) {: []),];- const showRecordingActions: ActionType[] = [- {- id: "view_recordings",- label: t("view_recordings"),- onClick: () => {- setViewRecordingsDialogIsOpen(true);- },- disabled: mutation.isLoading,- },- ];-let bookedActions: ActionType[] = [{id: "cancel",@@ -270,11 +259,21 @@ function BookingListItem(booking: BookingItemProps) {const bookingLink = buildBookingLink();const title = booking.title;- // To be used after we run query on legacy bookings- // const showRecordingsButtons = booking.isRecorded && isPast && isConfirmed;- const showRecordingsButtons =- (booking.location === "integrations:daily" || booking?.location?.trim() === "") && isPast && isConfirmed;+ const showRecordingsButtons = !!(booking.isRecorded && isPast && isConfirmed);+ const checkForRecordingsButton =+ !showRecordingsButtons && (booking.location === "integrations:daily" || booking?.location?.trim() === "");++ const showRecordingActions: ActionType[] = [+ {+ id: checkForRecordingsButton ? "check_for_recordings" : "view_recordings",+ label: checkForRecordingsButton ? t("check_for_recordings") : t("view_recordings"),+ onClick: () => {+ setViewRecordingsDialogIsOpen(true);+ },+ disabled: mutation.isLoading,+ },+ ];return (<>@@ -299,7 +298,7 @@ function BookingListItem(booking: BookingItemProps) {paymentCurrency={booking.payment[0].currency}/>)}- {showRecordingsButtons && (+ {(showRecordingsButtons || checkForRecordingsButton) && (<ViewRecordingsDialogbooking={booking}isOpenDialog={viewRecordingsDialogIsOpen}@@ -469,7 +468,9 @@ function BookingListItem(booking: BookingItemProps) {</>) : null}{isPast && isPending && !isConfirmed ? <TableActions actions={bookedActions} /> : null}- {showRecordingsButtons && <TableActions actions={showRecordingActions} />}+ {(showRecordingsButtons || checkForRecordingsButton) && (+ <TableActions actions={showRecordingActions} />+ )}{isCancelled && booking.rescheduled && (<div className="hidden h-full items-center md:flex"><RequestSentMessage />diff --git a/apps/web/pages/api/recorded-daily-video.ts b/apps/web/pages/api/recorded-daily-video.tsindex 0ce22581a8c..c35a9d5c7f3 100644--- a/apps/web/pages/api/recorded-daily-video.ts+++ b/apps/web/pages/api/recorded-daily-video.ts@@ -62,6 +62,46 @@ const triggerWebhook = async ({await Promise.all(promises);};+const checkIfUserIsPartOfTheSameTeam = async (+ teamId: number | undefined | null,+ userId: number,+ userEmail: string | undefined | null+) => {+ if (!teamId) return false;++ const getUserQuery = () => {+ if (!!userEmail) {+ return {+ OR: [+ {+ id: userId,+ },+ {+ email: userEmail,+ },+ ],+ };+ } else {+ return {+ id: userId,+ };+ }+ };++ const team = await prisma.team.findFirst({+ where: {+ id: teamId,+ members: {+ some: {+ user: getUserQuery(),+ },+ },+ },+ });++ return !!team;+};+async function handler(req: NextApiRequest, res: NextApiResponse) {if (!process.env.SENDGRID_API_KEY || !process.env.SENDGRID_EMAIL) {return res.status(405).json({ message: "No SendGrid API key or email" });@@ -137,12 +177,22 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {const isUserAttendeeOrOrganiser =booking?.user?.id === session.user.id ||- attendeesList.find((attendee) => attendee.id === session.user.id);+ attendeesList.find(+ (attendee) => attendee.id === session.user.id || attendee.email === session.user.email+ );if (!isUserAttendeeOrOrganiser) {- return res.status(403).send({- message: "Unauthorised",- });+ const isUserMemberOfTheTeam = checkIfUserIsPartOfTheSameTeam(+ booking?.eventType?.teamId,+ session.user.id,+ session.user.email+ );++ if (!isUserMemberOfTheTeam) {+ return res.status(403).send({+ message: "Unauthorised",+ });+ }}await prisma.booking.update({@@ -202,7 +252,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {return res.status(403).json({ message: "User does not have team plan to send out emails" });} catch (err) {- console.warn("something_went_wrong", err);+ console.warn("Error in /recorded-daily-video", err);return res.status(500).json({ message: "something went wrong" });}}diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.jsonindex f0b6749d7bf..f80967618f2 100644--- a/apps/web/public/static/locales/en/common.json+++ b/apps/web/public/static/locales/en/common.json@@ -1296,6 +1296,7 @@"select_calendars": "Select which calendars you want to check for conflicts to prevent double bookings.","check_for_conflicts": "Check for conflicts","view_recordings": "View recordings",+ "check_for_recordings":"Check for recordings","adding_events_to": "Adding events to","follow_system_preferences": "Follow system preferences","custom_brand_colors": "Custom brand colors",diff --git a/packages/emails/templates/organizer-daily-video-download-recording-email.ts b/packages/emails/templates/organizer-daily-video-download-recording-email.tsindex 60c673ef5c6..714ba4f7e44 100644--- a/packages/emails/templates/organizer-daily-video-download-recording-email.ts+++ b/packages/emails/templates/organizer-daily-video-download-recording-email.ts@@ -50,8 +50,13 @@ export default class OrganizerDailyVideoDownloadRecordingEmail extends BaseEmailreturn this.getFormattedRecipientTime({ time: this.calEvent.endTime, format });}+ protected getLocale(): string {+ return this.calEvent.organizer.language.locale;+ }+protected getFormattedDate() {const organizerTimeFormat = this.calEvent.organizer.timeFormat || TimeFormat.TWELVE_HOUR;+return `${this.getOrganizerStart(organizerTimeFormat)} - ${this.getOrganizerEnd(organizerTimeFormat)}, ${this.t(this.getOrganizerStart("dddd").toLowerCase())}, ${this.t(diff --git a/packages/features/ee/video/ViewRecordingsDialog.tsx b/packages/features/ee/video/ViewRecordingsDialog.tsxindex 74563b35fde..6134304d256 100644--- a/packages/features/ee/video/ViewRecordingsDialog.tsx+++ b/packages/features/ee/video/ViewRecordingsDialog.tsx@@ -174,7 +174,7 @@ export const ViewRecordingsDialog = (props: IViewRecordingsDialog) => {return (<Dialog open={isOpenDialog} onOpenChange={setIsOpenDialog}>- <DialogContent>+ <DialogContent enableOverflow><DialogHeader title={t("recordings_title")} subtitle={subtitle} />{roomName ? (<LicenseRequired>