Files
calendar/packages/emails/oauth-email-service.ts
e2119879ae refactor: apply biome formatting to packages/sms, prisma, emails, lib (#27880)
* refactor: apply biome formatting to small packages + packages/lib

Format packages/sms, packages/prisma, packages/platform/libraries,
packages/platform/examples, packages/platform/types, packages/emails,
and packages/lib.

Excludes packages/platform/examples/base/src/pages/[bookingUid].tsx
due to pre-existing lint errors.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* revert: remove packages/platform formatting changes

Revert biome formatting for packages/platform as requested.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
2026-02-13 07:39:01 -03:00

37 lines
1.5 KiB
TypeScript

import type BaseEmail from "@calcom/emails/templates/_base-email";
import type { OAuthClientNotification } from "./templates/admin-oauth-client-notification";
import AdminOAuthClientNotification from "./templates/admin-oauth-client-notification";
import type { OAuthClientApprovedNotification } from "./templates/oauth-client-approved-notification";
import OAuthClientApprovedEmail from "./templates/oauth-client-approved-notification";
import type { OAuthClientRejectedNotification } from "./templates/oauth-client-rejected-notification";
import OAuthClientRejectedEmail from "./templates/oauth-client-rejected-notification";
const sendEmail = async (prepare: () => BaseEmail) => {
let email: BaseEmail | undefined;
try {
email = prepare();
return await email.sendEmail();
} catch (e) {
const errorName = e instanceof Error ? e.name : "UnknownError";
console.error(
`${email?.constructor?.name ?? "Email"}.sendEmail oauth-email-service failed (${errorName})`,
e
);
throw e;
}
};
export const sendAdminOAuthClientNotification = async (input: OAuthClientNotification) => {
await sendEmail(() => new AdminOAuthClientNotification(input));
};
export const sendOAuthClientApprovedNotification = async (input: OAuthClientApprovedNotification) => {
await sendEmail(() => new OAuthClientApprovedEmail(input));
};
export const sendOAuthClientRejectedNotification = async (input: OAuthClientRejectedNotification) => {
await sendEmail(() => new OAuthClientRejectedEmail(input));
};