refactor: Split EmailManager into focused service files (#24997)

* refactor: Split EmailManager into focused service files

- Created separate service files for different email categories:
  - auth-email-service.ts: Authentication and verification emails
  - organization-email-service.ts: Organization and team emails
  - billing-email-service.ts: Payment and credit-related emails
  - integration-email-service.ts: Integration and app-related emails
  - workflow-email-service.ts: Workflow and custom emails
  - recording-email-service.ts: Recording and transcript emails

- Refactored email-manager.ts to keep only core booking lifecycle functions
- Removed unused imports from email-manager.ts
- Updated index.ts to export from all new service files
- Updated all imports across the codebase to use package root (@calcom/emails)
- Fixed lint warnings in handleChildrenEventTypes.ts

This reduces the import cost of EmailManager by allowing consumers to import only the specific email services they need.

Co-Authored-By: [email protected] <[email protected]>

* refactor: Update all imports to use direct service file paths

- Update 49 files to import directly from service files instead of barrel file
- Update packages/emails/index.ts to keep only email-manager and renderEmail exports
- Fix dynamic import in passwordResetRequest.ts
- Update renderEmail imports to use direct path
- Update test file to import from specific service module
- Fix ESLint warnings in modified files (unused variables, unused expressions)

This ensures consumers only import the specific email services they need,
reducing import cost by avoiding the barrel file pattern for service files.

Co-Authored-By: [email protected] <[email protected]>

* fix: Use default import for renderEmail

renderEmail is exported as a default export, not a named export.
Changed from 'import { renderEmail }' to 'import renderEmail'.

Co-Authored-By: [email protected] <[email protected]>

* fix: Update test mocks to use direct service file imports

- Update handleNoShowFee.test.ts to mock @calcom/emails/billing-email-service
- Update credit-service.test.ts to mock @calcom/emails/billing-email-service
- These tests were failing because they were mocking the barrel file @calcom/emails
  which no longer exports service functions after the refactoring

Co-Authored-By: [email protected] <[email protected]>

* fix: unit test spy

* fix: unit test mock

* address cubic comments

* fix: type error sendMonthlyDigestEmail

* remove barrel file and sendEmail unused task

* fixup! remove barrel file and sendEmail unused task

* fixup! fixup! remove barrel file and sendEmail unused task

* fix: integration test mock emails

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: hbjORbj <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-11-11 14:21:10 +02:00
1 parent 4407a1952c
commit a73b804d48
66 files changed
+477 -420

No files matched your search

@@ -51,7 +51,7 @@ const passwordResetRequest = async (user: Pick<User, "email" | "name" | "locale"
const t = await getTranslation(user.locale ?? "en", "common");
await guardAgainstTooManyPasswordResets(email);
const resetLink = await createPasswordReset(email);
const { sendPasswordResetEmail } = await import("@calcom/emails");
const { sendPasswordResetEmail } = await import("@calcom/emails/auth-email-service");
// send email in user language
await sendPasswordResetEmail({
+1 -1
View File
@@ -5,7 +5,7 @@ import {
sendEmailVerificationCode,
sendEmailVerificationLink,
sendChangeOfEmailVerificationLink,
} from "@calcom/emails/email-manager";
} from "@calcom/emails/auth-email-service";
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
import { sentrySpan } from "@calcom/features/watchlist/lib/telemetry";
import { checkIfEmailIsBlockedInWatchlistController } from "@calcom/features/watchlist/operations/check-if-email-in-watchlist.controller";
@@ -16,7 +16,7 @@ import {
sendOrganizerRequestEmail,
sendAttendeeRequestEmailAndSMS,
sendAddGuestsEmailsAndSMS,
} from "@calcom/emails";
} from "@calcom/emails/email-manager";
import type { BookingType } from "@calcom/features/bookings/lib/handleNewBooking/originalRescheduledBookingUtils";
import type { EventNameObjectType } from "@calcom/features/eventtypes/lib/eventNaming";
import { getPiiFreeCalendarEvent } from "@calcom/lib/piiFreeData";
@@ -1,4 +1,4 @@
import { sendAttendeeRequestEmailAndSMS, sendOrganizerRequestEmail } from "@calcom/emails";
import { sendAttendeeRequestEmailAndSMS, sendOrganizerRequestEmail } from "@calcom/emails/email-manager";
import { getWebhookPayloadForBooking } from "@calcom/features/bookings/lib/getWebhookPayloadForBooking";
import { WorkflowService } from "@calcom/features/ee/workflows/lib/service/WorkflowService";
import type { Workflow } from "@calcom/features/ee/workflows/lib/types";
@@ -4,7 +4,7 @@ import { DailyLocationType } from "@calcom/app-store/constants";
import { FAKE_DAILY_CREDENTIAL } from "@calcom/app-store/dailyvideo/lib/VideoApiAdapter";
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";
import dayjs from "@calcom/dayjs";
import { sendCancelledEmailsAndSMS } from "@calcom/emails";
import { sendCancelledEmailsAndSMS } from "@calcom/emails/email-manager";
import EventManager from "@calcom/features/bookings/lib/EventManager";
import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";
import { processNoShowFeeOnCancellation } from "@calcom/features/bookings/lib/payment/processNoShowFeeOnCancellation";
@@ -1,6 +1,6 @@
import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils";
import { scheduleMandatoryReminder } from "@calcom/ee/workflows/lib/reminders/scheduleMandatoryReminder";
import { sendScheduledEmailsAndSMS } from "@calcom/emails";
import { sendScheduledEmailsAndSMS } from "@calcom/emails/email-manager";
import type { EventManagerUser } from "@calcom/features/bookings/lib/EventManager";
import EventManager, { placeholderCreatedEvent } from "@calcom/features/bookings/lib/EventManager";
import { getBookerBaseUrl } from "@calcom/features/ee/organizations/lib/getBookerUrlServer";
@@ -110,8 +110,6 @@ export async function handleConfirmation(args: {
metadata.entryPoints = results[0].createdEvent?.entryPoints;
}
try {
const eventType = booking.eventType;
let isHostConfirmationEmailsDisabled = false;
let isAttendeeConfirmationEmailDisabled = false;
@@ -1,7 +1,7 @@
import { getCalendar } from "@calcom/app-store/_utils/getCalendar";
import { getAllDelegationCredentialsForUserIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential";
import { getDelegationCredentialOrFindRegularCredential } from "@calcom/app-store/delegationCredential";
import { sendCancelledSeatEmailsAndSMS } from "@calcom/emails";
import { sendCancelledSeatEmailsAndSMS } from "@calcom/emails/email-manager";
import { updateMeeting } from "@calcom/features/conferencing/lib/videoClient";
import { WorkflowRepository } from "@calcom/features/ee/workflows/repositories/WorkflowRepository";
import sendPayload from "@calcom/features/webhooks/lib/sendOrSchedulePayload";
@@ -116,7 +116,7 @@ async function cancelAttendeeSeat(
try {
await Promise.all(integrationsToUpdate);
} catch (error) {
} catch {
// Shouldn't stop code execution if integrations fail
// as integrations was already updated
}
@@ -1,9 +1,9 @@
// eslint-disable-next-line no-restricted-imports
import { cloneDeep } from "lodash";
import { uuid } from "short-uuid";
import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils";
import { sendScheduledSeatsEmailsAndSMS } from "@calcom/emails";
import { sendScheduledSeatsEmailsAndSMS } from "@calcom/emails/email-manager";
import { refreshCredentials } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/refreshCredentials";
import { handlePayment } from "@calcom/features/bookings/lib/handlePayment";
import {
@@ -1,7 +1,7 @@
// eslint-disable-next-line no-restricted-imports
import { cloneDeep } from "lodash";
import { sendRescheduledSeatEmailAndSMS } from "@calcom/emails";
import { sendRescheduledSeatEmailAndSMS } from "@calcom/emails/email-manager";
import type EventManager from "@calcom/features/bookings/lib/EventManager";
import { getTranslation } from "@calcom/lib/server/i18n";
import prisma from "@calcom/prisma";
@@ -1,8 +1,8 @@
// eslint-disable-next-line no-restricted-imports
import { cloneDeep } from "lodash";
import { uuid } from "short-uuid";
import { sendRescheduledEmailsAndSMS } from "@calcom/emails";
import { sendRescheduledEmailsAndSMS } from "@calcom/emails/email-manager";
import type EventManager from "@calcom/features/bookings/lib/EventManager";
import { ErrorCode } from "@calcom/lib/errorCodes";
import { HttpError } from "@calcom/lib/http-error";
@@ -1,7 +1,7 @@
// eslint-disable-next-line no-restricted-imports
import { cloneDeep } from "lodash";
import { sendRescheduledEmailsAndSMS } from "@calcom/emails";
import { sendRescheduledEmailsAndSMS } from "@calcom/emails/email-manager";
import type EventManager from "@calcom/features/bookings/lib/EventManager";
import prisma from "@calcom/prisma";
import type { AdditionalInformation, AppsStatus } from "@calcom/types/Calendar";
@@ -1,7 +1,7 @@
import { describe, expect, it, vi, beforeEach } from "vitest";
import { PaymentServiceMap } from "@calcom/app-store/payment.services.generated";
import { sendNoShowFeeChargedEmail } from "@calcom/emails";
import { sendNoShowFeeChargedEmail } from "@calcom/emails/billing-email-service";
import { CredentialRepository } from "@calcom/features/credentials/repositories/CredentialRepository";
import { TeamRepository } from "@calcom/features/ee/teams/repositories/TeamRepository";
import { MembershipRepository } from "@calcom/features/membership/repositories/MembershipRepository";
@@ -21,7 +21,7 @@ vi.mock("@calcom/app-store/payment.services.generated", () => ({
},
}));
vi.mock("@calcom/emails", () => ({
vi.mock("@calcom/emails/billing-email-service", () => ({
sendNoShowFeeChargedEmail: vi.fn(),
}));
@@ -1,7 +1,7 @@
import { PaymentServiceMap } from "@calcom/app-store/payment.services.generated";
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";
import dayjs from "@calcom/dayjs";
import { sendNoShowFeeChargedEmail } from "@calcom/emails";
import { sendNoShowFeeChargedEmail } from "@calcom/emails/billing-email-service";
import { CredentialRepository } from "@calcom/features/credentials/repositories/CredentialRepository";
import { TeamRepository } from "@calcom/features/ee/teams/repositories/TeamRepository";
import { MembershipRepository } from "@calcom/features/membership/repositories/MembershipRepository";
@@ -1,4 +1,4 @@
import { sendOrganizerPaymentRefundFailedEmail } from "@calcom/emails";
import { sendOrganizerPaymentRefundFailedEmail } from "@calcom/emails/billing-email-service";
import type { CalendarEvent } from "@calcom/types/Calendar";
const handleRefundError = async (opts: { event: CalendarEvent; reason: string; paymentId: string }) => {
@@ -4,7 +4,7 @@ import { v5 as uuidv5 } from "uuid";
import { DailyLocationType } from "@calcom/app-store/constants";
import { getDailyAppKeys } from "@calcom/app-store/dailyvideo/lib/getDailyAppKeys";
import { getVideoAdapters } from "@calcom/app-store/getVideoAdapters";
import { sendBrokenIntegrationEmail } from "@calcom/emails";
import { sendBrokenIntegrationEmail } from "@calcom/emails/integration-email-service";
import { getUid } from "@calcom/lib/CalEventParser";
import logger from "@calcom/lib/logger";
import { getPiiFreeCalendarEvent, getPiiFreeCredential } from "@calcom/lib/piiFreeData";
@@ -161,7 +161,7 @@ const createMeetingWithCalVideo = async (calEvent: CalendarEvent) => {
let dailyAppKeys: Awaited<ReturnType<typeof getDailyAppKeys>>;
try {
dailyAppKeys = await getDailyAppKeys();
} catch (e) {
} catch {
return;
}
const [videoAdapter] = await getVideoAdapters([
@@ -184,7 +184,7 @@ export const createInstantMeetingWithCalVideo = async (endTime: string) => {
let dailyAppKeys: Awaited<ReturnType<typeof getDailyAppKeys>>;
try {
dailyAppKeys = await getDailyAppKeys();
} catch (e) {
} catch {
return;
}
const [videoAdapter] = await getVideoAdapters([
@@ -209,7 +209,7 @@ const getRecordingsOfCalVideoByRoomName = async (
let dailyAppKeys: Awaited<ReturnType<typeof getDailyAppKeys>>;
try {
dailyAppKeys = await getDailyAppKeys();
} catch (e) {
} catch {
console.error("Error: Cal video provider is not installed.");
return;
}
@@ -235,7 +235,7 @@ const getDownloadLinkOfCalVideoByRecordingId = async (
let dailyAppKeys: Awaited<ReturnType<typeof getDailyAppKeys>>;
try {
dailyAppKeys = await getDailyAppKeys();
} catch (e) {
} catch {
console.error("Error: Cal video provider is not installed.");
return;
}
@@ -259,7 +259,7 @@ const getAllTranscriptsAccessLinkFromRoomName = async (roomName: string) => {
let dailyAppKeys: Awaited<ReturnType<typeof getDailyAppKeys>>;
try {
dailyAppKeys = await getDailyAppKeys();
} catch (e) {
} catch {
console.error("Error: Cal video provider is not installed.");
return;
}
@@ -283,7 +283,7 @@ const getAllTranscriptsAccessLinkFromMeetingId = async (meetingId: string) => {
let dailyAppKeys: Awaited<ReturnType<typeof getDailyAppKeys>>;
try {
dailyAppKeys = await getDailyAppKeys();
} catch (e) {
} catch {
console.error("Error: Cal video provider is not installed.");
return;
}
@@ -307,7 +307,7 @@ const submitBatchProcessorTranscriptionJob = async (recordingId: string) => {
let dailyAppKeys: Awaited<ReturnType<typeof getDailyAppKeys>>;
try {
dailyAppKeys = await getDailyAppKeys();
} catch (e) {
} catch {
console.error("Error: Cal video provider is not installed.");
return;
}
@@ -343,7 +343,7 @@ const getTranscriptsAccessLinkFromRecordingId = async (recordingId: string) => {
let dailyAppKeys: Awaited<ReturnType<typeof getDailyAppKeys>>;
try {
dailyAppKeys = await getDailyAppKeys();
} catch (e) {
} catch {
console.error("Error: Cal video provider is not installed.");
return;
}
@@ -368,7 +368,7 @@ const checkIfRoomNameMatchesInRecording = async (roomName: string, recordingId:
let dailyAppKeys: Awaited<ReturnType<typeof getDailyAppKeys>>;
try {
dailyAppKeys = await getDailyAppKeys();
} catch (e) {
} catch {
console.error("Error: Cal video provider is not installed.");
return;
}
@@ -8,7 +8,7 @@ import {
eventTypeAppMetadataOptionalSchema,
} from "@calcom/app-store/zod-utils";
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";
import { sendCancelledEmailsAndSMS } from "@calcom/emails";
import { sendCancelledEmailsAndSMS } from "@calcom/emails/email-manager";
import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";
import { deletePayment } from "@calcom/features/bookings/lib/payment/deletePayment";
import { deleteWebhookScheduledTriggers } from "@calcom/features/webhooks/lib/scheduleTrigger";
@@ -2,7 +2,7 @@ import Stripe from "stripe";
import { describe, it, expect, beforeEach, vi } from "vitest";
import dayjs from "@calcom/dayjs";
import * as EmailManager from "@calcom/emails/email-manager";
import * as EmailManager from "@calcom/emails/billing-email-service";
import getOrgIdFromMemberOrTeamId from "@calcom/lib/getOrgIdFromMemberOrTeamId";
import { CreditsRepository } from "@calcom/lib/server/repository/credits";
import { MembershipRepository } from "@calcom/features/membership/repositories/MembershipRepository";
@@ -70,7 +70,7 @@ vi.mock("@calcom/prisma/enums", async (importOriginal) => {
vi.mock("@calcom/lib/server/repository/credits");
vi.mock("@calcom/features/membership/repositories/MembershipRepository");
vi.mock("@calcom/features/ee/teams/repositories/TeamRepository");
vi.mock("@calcom/emails/email-manager", () => ({
vi.mock("@calcom/emails/billing-email-service", () => ({
sendCreditBalanceLimitReachedEmails: vi.fn().mockResolvedValue(undefined),
sendCreditBalanceLowWarningEmails: vi.fn().mockResolvedValue(undefined),
}));
@@ -4,7 +4,7 @@ import dayjs from "@calcom/dayjs";
import {
sendCreditBalanceLimitReachedEmails,
sendCreditBalanceLowWarningEmails,
} from "@calcom/emails/email-manager";
} from "@calcom/emails/billing-email-service";
import { StripeBillingService } from "@calcom/features/ee/billing/stripe-billing-service";
import { InternalTeamBilling } from "@calcom/features/ee/billing/teams/internal-team-billing";
import { TeamRepository } from "@calcom/features/ee/teams/repositories/TeamRepository";
@@ -1,4 +1,4 @@
import { sendCreditBalanceLimitReachedEmails } from "@calcom/emails/email-manager";
import { sendCreditBalanceLimitReachedEmails } from "@calcom/emails/billing-email-service";
import logger from "@calcom/lib/logger";
import type { PrismaClient } from "@calcom/prisma";
import type { CreditUsageType } from "@calcom/prisma/enums";
@@ -1,8 +1,8 @@
// eslint-disable-next-line no-restricted-imports
import type { DeepMockProxy } from "vitest-mock-extended";
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";
import { sendSlugReplacementEmail } from "@calcom/emails/email-manager";
import { sendSlugReplacementEmail } from "@calcom/emails/integration-email-service";
import { getTranslation } from "@calcom/lib/server/i18n";
import type { PrismaClient } from "@calcom/prisma";
import type { Prisma } from "@calcom/prisma/client";
@@ -93,7 +93,7 @@ export default async function handleChildrenEventTypes({
children,
prisma,
profileId,
updatedValues,
updatedValues: _updatedValues,
}: handleChildrenEventTypesProps) {
// Check we are dealing with a managed event type
if (updatedEventType?.schedulingType !== SchedulingType.MANAGED)
@@ -222,7 +222,7 @@ export default async function handleChildrenEventTypes({
teamName: oldEventType.team?.name || null,
});
const { unlockedFields } = managedEventTypeValues.metadata?.managedEventConfig;
const { unlockedFields } = managedEventTypeValues.metadata?.managedEventConfig ?? {};
const unlockedFieldProps = !unlockedFields
? {}
: Object.keys(unlockedFields).reduce((acc, key) => {
@@ -1,7 +1,7 @@
import { lookup } from "dns";
import { type TFunction } from "i18next";
import { sendAdminOrganizationNotification } from "@calcom/emails";
import { sendAdminOrganizationNotification } from "@calcom/emails/organization-email-service";
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
import { UserRepository } from "@calcom/features/users/repositories/UserRepository";
import {
@@ -1,6 +1,6 @@
import type { TFunction } from "i18next";
import { sendOrganizationCreationEmail } from "@calcom/emails/email-manager";
import { sendOrganizationCreationEmail } from "@calcom/emails/organization-email-service";
import { sendEmailVerification } from "@calcom/features/auth/lib/verifyEmail";
import { getOrgFullOrigin } from "@calcom/features/ee/organizations/lib/orgDomains";
import {
+2 -2
View File
@@ -4,7 +4,8 @@ import type Stripe from "stripe";
import { handlePaymentSuccess } from "@calcom/app-store/_utils/payments/handlePaymentSuccess";
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";
import { sendAttendeeRequestEmailAndSMS, sendOrganizerRequestEmail } from "@calcom/emails";
import { sendAttendeeRequestEmailAndSMS, sendOrganizerRequestEmail } from "@calcom/emails/email-manager";
import EventManager, { placeholderCreatedEvent } from "@calcom/features/bookings/lib/EventManager";
import { doesBookingRequireConfirmation } from "@calcom/features/bookings/lib/doesBookingRequireConfirmation";
import { getAllCredentialsIncludeServiceAccountKey } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials";
import { handleConfirmation } from "@calcom/features/bookings/lib/handleConfirmation";
@@ -12,7 +13,6 @@ import { getBooking } from "@calcom/features/bookings/lib/payment/getBooking";
import stripe from "@calcom/features/ee/payments/server/stripe";
import { getPlatformParams } from "@calcom/features/platform-oauth-client/get-platform-params";
import { PlatformOAuthClientRepository } from "@calcom/features/platform-oauth-client/platform-oauth-client.repository";
import EventManager, { placeholderCreatedEvent } from "@calcom/features/bookings/lib/EventManager";
import { IS_PRODUCTION } from "@calcom/lib/constants";
import { getErrorFromUnknown } from "@calcom/lib/errors";
import { HttpError as HttpCode } from "@calcom/lib/http-error";
@@ -466,7 +466,7 @@ describe("roundRobinManualReassignment test", () => {
await mockEventManagerReschedule();
const sendRoundRobinReassignedEmailsAndSMSSpy = vi.spyOn(
await import("@calcom/emails"),
await import("@calcom/emails/email-manager"),
"sendRoundRobinReassignedEmailsAndSMS"
);
@@ -1,7 +1,5 @@
import { cloneDeep } from "lodash";
import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential";
import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils";
import dayjs from "@calcom/dayjs";
@@ -9,16 +7,21 @@ import {
sendRoundRobinReassignedEmailsAndSMS,
sendRoundRobinScheduledEmailsAndSMS,
sendRoundRobinUpdatedEmailsAndSMS,
} from "@calcom/emails";
} from "@calcom/emails/email-manager";
import EventManager from "@calcom/features/bookings/lib/EventManager";
import { getAllCredentialsIncludeServiceAccountKey } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials";
import { getBookingResponsesPartialSchema } from "@calcom/features/bookings/lib/getBookingResponsesSchema";
import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";
import { getEventTypesFromDB } from "@calcom/features/bookings/lib/handleNewBooking/getEventTypesFromDB";
import { getBookerBaseUrl } from "@calcom/features/ee/organizations/lib/getBookerUrlServer";
import AssignmentReasonRecorder, { RRReassignmentType } from "@calcom/features/ee/round-robin/assignmentReason/AssignmentReasonRecorder";
import AssignmentReasonRecorder, {
RRReassignmentType,
} from "@calcom/features/ee/round-robin/assignmentReason/AssignmentReasonRecorder";
import { BookingLocationService } from "@calcom/features/ee/round-robin/lib/bookingLocationService";
import { scheduleEmailReminder, deleteScheduledEmailReminder } from "@calcom/features/ee/workflows/lib/reminders/emailReminderManager";
import {
scheduleEmailReminder,
deleteScheduledEmailReminder,
} from "@calcom/features/ee/workflows/lib/reminders/emailReminderManager";
import { scheduleWorkflowReminders } from "@calcom/features/ee/workflows/lib/reminders/reminderScheduler";
import { getEventName } from "@calcom/features/eventtypes/lib/eventNaming";
import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser";
@@ -33,15 +36,12 @@ import { WorkflowActions, WorkflowMethods, WorkflowTriggerEvents } from "@calcom
import type { EventTypeMetadata, PlatformClientParams } from "@calcom/prisma/zod-utils";
import type { CalendarEvent } from "@calcom/types/Calendar";
import { handleRescheduleEventManager } from "./handleRescheduleEventManager";
import type { BookingSelectResult } from "./utils/bookingSelect";
import { bookingSelect } from "./utils/bookingSelect";
import { getDestinationCalendar } from "./utils/getDestinationCalendar";
import { getTeamMembers } from "./utils/getTeamMembers";
enum ErrorCode {
InvalidRoundRobinHost = "invalid_round_robin_host",
UserIsFixed = "user_is_round_robin_fixed",
@@ -615,4 +615,4 @@ export async function handleWorkflowsUpdate({
});
}
export default roundRobinManualReassignment;
export default roundRobinManualReassignment;
@@ -1,7 +1,5 @@
import { cloneDeep } from "lodash";
import {
enrichHostsWithDelegationCredentials,
enrichUserWithDelegationCredentialsIncludeServiceAccountKey,
@@ -13,7 +11,7 @@ import {
sendRoundRobinReassignedEmailsAndSMS,
sendRoundRobinScheduledEmailsAndSMS,
sendRoundRobinUpdatedEmailsAndSMS,
} from "@calcom/emails";
} from "@calcom/emails/email-manager";
import EventManager from "@calcom/features/bookings/lib/EventManager";
import { getAllCredentialsIncludeServiceAccountKey } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials";
import { getBookingResponsesPartialSchema } from "@calcom/features/bookings/lib/getBookingResponsesSchema";
@@ -519,4 +517,4 @@ export const roundRobinReassignment = async ({
};
};
export default roundRobinReassignment;
export default roundRobinReassignment;
@@ -1,4 +1,4 @@
import { sendCustomWorkflowEmail } from "@calcom/emails";
import { sendCustomWorkflowEmail } from "@calcom/emails/workflow-email-service";
import type { WorkflowEmailData } from "@calcom/emails/templates/workflow-email";
import tasker from "@calcom/features/tasker";
-1
View File
@@ -2,7 +2,6 @@ import type { z } from "zod";
export type TaskerTypes = "internal" | "redis";
type TaskPayloads = {
sendEmail: string;
sendWebhook: string;
sendSms: string;
triggerHostNoShowWebhook: z.infer<
-1
View File
@@ -8,7 +8,6 @@ import type { TaskHandler, TaskTypes } from "../tasker";
* The task handlers are imported dynamically to avoid circular dependencies.
*/
const tasks: Record<TaskTypes, () => Promise<TaskHandler>> = {
sendEmail: () => import("./sendEmail").then((module) => module.sendEmail),
sendWebhook: () => import("./sendWebook").then((module) => module.sendWebhook),
triggerHostNoShowWebhook: () =>
import("./triggerNoShow/triggerHostNoShow").then((module) => module.triggerHostNoShow),
@@ -1,25 +0,0 @@
import { z } from "zod";
const sendEmailPayloadSchema = z.object({
/** */
to: z.string(),
/** The email template to send */
template: z.string(),
payload: z.string(),
});
export async function sendEmail(payload: string): Promise<void> {
try {
const parsedPayload = sendEmailPayloadSchema.parse(JSON.parse(payload));
console.log(parsedPayload);
const emails = await import("@calcom/emails");
const email = emails[parsedPayload.template as keyof typeof emails];
if (!email) throw new Error("Invalid email template");
// @ts-expect-error - TODO bring back email type safety
await email(parsedPayload.to);
} catch (error) {
// ... handle error
console.error(error);
throw error;
}
}
@@ -1,6 +1,6 @@
import { z } from "zod";
import { sendCustomWorkflowEmail } from "@calcom/emails";
import { sendCustomWorkflowEmail } from "@calcom/emails/workflow-email-service";
export const ZSendWorkflowEmailsSchema = z.object({
to: z.array(z.string()),