* Add email domain array * Create numbered email domain object * Check email domain * Rename function * Add tests * Frontend enable skip ownership check if free email domain * Backend ignore adding ownership to return records if free email domain check is enabled * feat: Only require confirmation for free email domains (#17917) * Add requiresConfirmationForFreeEmail to db * Add option to event type settings * Get requiresConfirmationForFreeEmail for event type page * Include requiresConfirmationForFreeEmail in fetching event type * Pass bookerEmail to `getRequiresConfirmationFlags` * Add free email domain check to `determineRequiresConfirmation` * Add `requiresConfirmationForFreeEmail` to types * Add severity to Watchlist table * Add migration for watchlist severity * Add `getEmailDomainInWatchlist` method to watchlist repository * Use watchlist repository to check for free email domain * Mock watchlist repository in test * Update test * Rename method * Add severity to blocked list * Move check free email domain to async * Type checks * Adjust for promise returned * Fix tests * Fix * Fix tests
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { captureException } from "@sentry/nextjs";
|
|
|
|
import db from "@calcom/prisma";
|
|
import { WatchlistType, WatchlistSeverity } from "@calcom/prisma/enums";
|
|
|
|
import type { IWatchlistRepository } from "./watchlist.repository.interface";
|
|
|
|
export class WatchlistRepository implements IWatchlistRepository {
|
|
async getBlockedEmailInWatchlist(email: string) {
|
|
const [, domain] = email.split("@");
|
|
try {
|
|
const emailInWatchlist = await db.watchlist.findFirst({
|
|
where: {
|
|
severity: WatchlistSeverity.CRITICAL,
|
|
OR: [
|
|
{ type: WatchlistType.EMAIL, value: email },
|
|
{ type: WatchlistType.DOMAIN, value: domain },
|
|
],
|
|
},
|
|
});
|
|
return emailInWatchlist;
|
|
} catch (err) {
|
|
captureException(err);
|
|
throw err;
|
|
}
|
|
}
|
|
|
|
async getFreeEmailDomainInWatchlist(emailDomain: string) {
|
|
try {
|
|
const domainInWatchWatchlist = await db.watchlist.findFirst({
|
|
where: {
|
|
type: WatchlistType.DOMAIN,
|
|
value: emailDomain,
|
|
},
|
|
});
|
|
return domainInWatchWatchlist;
|
|
} catch (err) {
|
|
captureException(err);
|
|
throw err;
|
|
}
|
|
}
|
|
}
|