1 import { INCOMING_DEFAULTS_LOCATION } from '../constants';
2 import type { IncomingDefault } from '../interfaces';
5 * Check if an email address is inside email in incomingDefaults
7 const isAddressIncluded = (
8 incomingDefaults: IncomingDefault[] = [],
10 location?: INCOMING_DEFAULTS_LOCATION
11 ): IncomingDefault | undefined =>
12 incomingDefaults.find(({ Location, Email }: IncomingDefault) => {
13 if ((location && Location !== location) || !emailAddress) {
18 return Email === emailAddress;
24 export const isBlockedIncomingDefaultAddress = (incomingDefaults: IncomingDefault[], emailAddress: string): boolean => {
25 const foundItem = isAddressIncluded(incomingDefaults, emailAddress, INCOMING_DEFAULTS_LOCATION.BLOCKED);
30 export const getBlockedIncomingDefaultByAddress = (
31 incomingDefaults: IncomingDefault[],
33 ): IncomingDefault | undefined => {
34 const foundItem = isAddressIncluded(incomingDefaults, emailAddress, INCOMING_DEFAULTS_LOCATION.BLOCKED);