Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / packages / shared / lib / helpers / incomingDefaults.ts
blob28eb93127539bd37a416a682e355b5b2ec34a3a2
1 import { INCOMING_DEFAULTS_LOCATION } from '../constants';
2 import type { IncomingDefault } from '../interfaces';
4 /**
5  * Check if an email address is inside email in incomingDefaults
6  */
7 const isAddressIncluded = (
8     incomingDefaults: IncomingDefault[] = [],
9     emailAddress: string,
10     location?: INCOMING_DEFAULTS_LOCATION
11 ): IncomingDefault | undefined =>
12     incomingDefaults.find(({ Location, Email }: IncomingDefault) => {
13         if ((location && Location !== location) || !emailAddress) {
14             return false;
15         }
17         if (Email) {
18             return Email === emailAddress;
19         }
21         return false;
22     });
24 export const isBlockedIncomingDefaultAddress = (incomingDefaults: IncomingDefault[], emailAddress: string): boolean => {
25     const foundItem = isAddressIncluded(incomingDefaults, emailAddress, INCOMING_DEFAULTS_LOCATION.BLOCKED);
27     return !!foundItem;
30 export const getBlockedIncomingDefaultByAddress = (
31     incomingDefaults: IncomingDefault[],
32     emailAddress: string
33 ): IncomingDefault | undefined => {
34     const foundItem = isAddressIncluded(incomingDefaults, emailAddress, INCOMING_DEFAULTS_LOCATION.BLOCKED);
36     return foundItem;