Files
calendar/packages/lib/freeEmailDomainCheck/checkIfFreeEmailDomain.ts
T
Joe Au-YeungandGitHub 8dda418127 feat: Salesforce skip ownership check if attendee email is a free domain (#17916)
* 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
2024-12-18 15:02:42 +00:00

15 lines
695 B
TypeScript

import { WatchlistRepository } from "@calcom/features/watchlist/watchlist.repository";
export const checkIfFreeEmailDomain = async (email: string) => {
const emailDomain = email.split("@")[1].toLowerCase();
// If there's no email domain return as if it was a free email domain
if (!emailDomain) return true;
// Gmail and Outlook are one of the most common email domains so we don't need to check the domains list
if (emailDomain === "gmail.com" || emailDomain === "outlook.com") return true;
// Check if email domain is in the watchlist
const watchlistRepository = new WatchlistRepository();
return !!(await watchlistRepository.getFreeEmailDomainInWatchlist(emailDomain));
};