feat: Use Watchlist on sending email verifications (#20114)

This commit is contained in:
Keith Williams
2025-03-16 14:20:20 +00:00
committed by GitHub
parent 73e7d6f986
commit 424d94f16d
+16
View File
@@ -7,6 +7,7 @@ import {
sendChangeOfEmailVerificationLink,
} from "@calcom/emails/email-manager";
import { getFeatureFlag } from "@calcom/features/flags/server/utils";
import { checkIfEmailIsBlockedInWatchlistController } from "@calcom/features/watchlist/operations/check-if-email-in-watchlist.controller";
import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
import { WEBAPP_URL } from "@calcom/lib/constants";
import logger from "@calcom/lib/logger";
@@ -40,6 +41,11 @@ export const sendEmailVerification = async ({
return { ok: true, skipped: true };
}
if (await checkIfEmailIsBlockedInWatchlistController(email)) {
log.warn("Email is blocked - not sending verification email", email);
return { ok: false, skipped: false };
}
if (isPlatform) {
log.warn("Skipping Email verification");
return { ok: true, skipped: true };
@@ -82,6 +88,11 @@ export const sendEmailVerificationByCode = async ({
username,
isVerifyingEmail,
}: VerifyEmailType) => {
if (await checkIfEmailIsBlockedInWatchlistController(email)) {
log.warn("Email is blocked - not sending verification email", email);
return { ok: false, skipped: false };
}
const translation = await getTranslation(language ?? "en", "common");
const secret = createHash("md5")
.update(email + process.env.CALENDSO_ENCRYPTION_KEY)
@@ -122,6 +133,11 @@ export const sendChangeOfEmailVerification = async ({ user, language }: ChangeOf
return { ok: true, skipped: true };
}
if (await checkIfEmailIsBlockedInWatchlistController(user.emailFrom)) {
log.warn("Email is blocked - not sending verification email", user.emailFrom);
return { ok: false, skipped: false };
}
await checkRateLimitAndThrowError({
rateLimitingType: "core",
identifier: user.emailFrom,