From 30eb7ce84625ab776449c5ec77c9f4acec66a094 Mon Sep 17 00:00:00 2001 From: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Date: Tue, 21 Jan 2025 11:37:10 +0530 Subject: [PATCH] feat: add transcription as attachment (#18740) * feat: add transcription as attachment * fix: change style --- apps/web/public/static/locales/en/common.json | 1 + .../templates/DailyVideoDownloadTranscriptEmail.tsx | 11 +++++------ ...ttendee-daily-video-download-transcript-email.ts | 13 +++++++++++++ ...ganizer-daily-video-download-transcript-email.ts | 13 +++++++++++++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index 430d3aee89c11c..d95cfa7f82f9f2 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -1544,6 +1544,7 @@ "download_transcript": "Download Transcript", "recording_from_your_recent_call": "A recording from your recent call on {{appName}} is ready for download", "transcript_from_previous_call": "Transcript from your recent call on {{appName}} is ready to download. Links are valid only for 1 Hour", + "you_can_download_transcript_from_attachments": "You can also download transcript from attachments", "link_valid_for_12_hrs": "Note: The download link is valid only for 12 hours. You can generate new download link by following instructions <1>here.", "create_your_first_form": "Create your first form", "create_your_first_form_description": "With Routing Forms you can ask qualifying questions and route to the correct person or event type.", diff --git a/packages/emails/src/templates/DailyVideoDownloadTranscriptEmail.tsx b/packages/emails/src/templates/DailyVideoDownloadTranscriptEmail.tsx index 316e370ed409c7..3c9fa5ae9fcfc6 100644 --- a/packages/emails/src/templates/DailyVideoDownloadTranscriptEmail.tsx +++ b/packages/emails/src/templates/DailyVideoDownloadTranscriptEmail.tsx @@ -1,8 +1,8 @@ import type { TFunction } from "next-i18next"; -import { WEBAPP_URL, APP_NAME, COMPANY_NAME } from "@calcom/lib/constants"; +import { WEBAPP_URL, COMPANY_NAME } from "@calcom/lib/constants"; -import { V2BaseEmailHtml, CallToAction } from "../components"; +import { V2BaseEmailHtml } from "../components"; interface DailyVideoDownloadTranscriptEmailProps { language: TFunction; @@ -55,13 +55,13 @@ export const DailyVideoDownloadTranscriptEmail = ( <>{props.language("hi_user_name", { name: props.name })},

- <>{props.language("transcript_from_previous_call", { appName: APP_NAME })} + <>{props.language("you_can_download_transcript_from_attachments")}

- {props.transcriptDownloadLinks.map((downloadLink, index) => { + {props.transcriptDownloadLinks.map((_, index) => { return (
{props.date} Transcript {index + 1}

-
); })} diff --git a/packages/emails/templates/attendee-daily-video-download-transcript-email.ts b/packages/emails/templates/attendee-daily-video-download-transcript-email.ts index 5c7355016c1e40..a063e212f866b8 100644 --- a/packages/emails/templates/attendee-daily-video-download-transcript-email.ts +++ b/packages/emails/templates/attendee-daily-video-download-transcript-email.ts @@ -21,6 +21,18 @@ export default class AttendeeDailyVideoDownloadTranscriptEmail extends BaseEmail this.t = attendee.language.translate; } protected async getNodeMailerPayload(): Promise> { + const attachments = await Promise.all( + this.transcriptDownloadLinks.map(async (url, index) => { + const response = await fetch(url); + const buffer = await response.arrayBuffer(); + return { + filename: `transcript-${index + 1}.vtt`, + content: Buffer.from(buffer), + contentType: "text/vtt", + }; + }) + ); + return { to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, @@ -36,6 +48,7 @@ export default class AttendeeDailyVideoDownloadTranscriptEmail extends BaseEmail language: this.t, name: this.attendee.name, }), + attachments, }; } diff --git a/packages/emails/templates/organizer-daily-video-download-transcript-email.ts b/packages/emails/templates/organizer-daily-video-download-transcript-email.ts index 058b48d954b4ec..7a41a35c587111 100644 --- a/packages/emails/templates/organizer-daily-video-download-transcript-email.ts +++ b/packages/emails/templates/organizer-daily-video-download-transcript-email.ts @@ -20,6 +20,18 @@ export default class OrganizerDailyVideoDownloadTranscriptEmail extends BaseEmai this.t = this.calEvent.organizer.language.translate; } protected async getNodeMailerPayload(): Promise> { + const attachments = await Promise.all( + this.transcriptDownloadLinks.map(async (url, index) => { + const response = await fetch(url); + const buffer = await response.arrayBuffer(); + return { + filename: `transcript-${index + 1}.vtt`, + content: Buffer.from(buffer), + contentType: "text/vtt", + }; + }) + ); + return { to: `${this.calEvent.organizer.email}>`, from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`, @@ -35,6 +47,7 @@ export default class OrganizerDailyVideoDownloadTranscriptEmail extends BaseEmai language: this.t, name: this.calEvent.organizer.name, }), + attachments, }; }