feat: allow link cloaking for Organization accounts in workflow emails (#26528)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Peer RichelsenandDevin AI authored and GitHub committed 2026-01-16 08:33:38 +00:00
1 parent 04c9453d5c
commit fc518bfdc1
6 files changed
+88 -18

No files matched your search

@@ -1,10 +1,8 @@
/**
* @deprecated use smtp with tasker instead
*/
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { v4 as uuidv4 } from "uuid";
import process from "node:process";
import dayjs from "@calcom/dayjs";
import generateIcsString from "@calcom/emails/lib/generateIcsString";
import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";
@@ -17,7 +15,9 @@ import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat";
import prisma from "@calcom/prisma";
import { SchedulingType, WorkflowActions, WorkflowTemplates } from "@calcom/prisma/enums";
import { bookingMetadataSchema } from "@calcom/prisma/zod-utils";
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { v4 as uuidv4 } from "uuid";
import {
getAllRemindersToCancel,
getAllRemindersToDelete,
@@ -33,9 +33,9 @@ import {
} from "../lib/reminders/providers/sendgridProvider";
import type { VariablesType } from "../lib/reminders/templates/customTemplate";
import customTemplate from "../lib/reminders/templates/customTemplate";
import { replaceCloakedLinksInHtml } from "../lib/reminders/utils";
import emailRatingTemplate from "../lib/reminders/templates/emailRatingTemplate";
import emailReminderTemplate from "../lib/reminders/templates/emailReminderTemplate";
import { replaceCloakedLinksInHtml } from "../lib/reminders/utils";
export async function handler(req: NextRequest) {
const apiKey = req.headers.get("authorization") || req.nextUrl.searchParams.get("apiKey");
@@ -126,7 +126,7 @@ export async function handler(req: NextRequest) {
// For seated events, get the correct attendee based on seatReferenceId
let targetAttendee = reminder.booking?.attendees[0];
if (reminder.seatReferenceId) {
const bookingSeatRepository = new BookingSeatRepository(prisma);
const bookingSeatRepository = new BookingSeatRepository(prisma);
const seatAttendeeData = await bookingSeatRepository.getByReferenceUidWithAttendeeDetails(
reminder.seatReferenceId
);
@@ -355,10 +355,17 @@ export async function handler(req: NextRequest) {
title: booking.title || booking.eventType?.title || "",
};
// Organization accounts are allowed to use cloaked links (URL behind text)
// since they are paid accounts with lower spam/scam risk
const isOrganization = reminder.workflowStep?.workflow?.team?.isOrganization ?? false;
const processedEmailBody = isOrganization
? emailContent.emailBody
: replaceCloakedLinksInHtml(emailContent.emailBody);
const mailData = {
subject: emailContent.emailSubject,
to: Array.isArray(sendTo) ? sendTo : [sendTo],
html: replaceCloakedLinksInHtml(emailContent.emailBody),
html: processedEmailBody,
attachments: reminder.workflowStep.includeCalendarEvent
? [
{
@@ -454,10 +461,17 @@ export async function handler(req: NextRequest) {
if (emailContent.emailSubject.length > 0 && !emailBodyEmpty && sendTo) {
const batchId = isSendgridEnabled ? await getBatchId() : undefined;
// Organization accounts are allowed to use cloaked links (URL behind text)
// since they are paid accounts with lower spam/scam risk
const isOrganization = reminder.workflowStep?.workflow?.team?.isOrganization ?? false;
const processedEmailBody = isOrganization
? emailContent.emailBody
: replaceCloakedLinksInHtml(emailContent.emailBody);
const mailData = {
subject: emailContent.emailSubject,
to: [sendTo],
html: replaceCloakedLinksInHtml(emailContent.emailBody),
html: processedEmailBody,
sender: reminder.workflowStep?.sender,
...(!reminder.booking?.eventType?.hideOrganizerEmail && {
replyTo: