-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Domains: Implement multi-target email forwards (#98837)"
This reverts commit a1abc2c.
- Loading branch information
Showing
35 changed files
with
754 additions
and
1,012 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
client/lib/domains/email-forwarding/has-duplicated-email-forwards.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* @param newEmailForward a string representing a new email forward | ||
* @returns { boolean } If the email forward is present in the existing email forwards collection | ||
*/ | ||
export function hasDuplicatedEmailForwards( newEmailForward, existingEmailForwards ) { | ||
return existingEmailForwards?.some( ( forward ) => forward.mailbox === newEmailForward ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,38 @@ | ||
import emailValidator from 'email-validator'; | ||
import { mapValues } from 'lodash'; | ||
import { hasDuplicatedEmailForwards } from 'calypso/lib/domains/email-forwarding/has-duplicated-email-forwards'; | ||
|
||
function validateAllFields( fieldValues, existingEmailForwards = [] ) { | ||
return mapValues( fieldValues, ( value, fieldName ) => { | ||
const isValid = validateField( { | ||
value, | ||
name: fieldName, | ||
} ); | ||
|
||
if ( ! isValid ) { | ||
return [ 'Invalid' ]; | ||
} | ||
|
||
if ( fieldName !== 'mailbox' ) { | ||
return []; | ||
} | ||
|
||
return hasDuplicatedEmailForwards( value, existingEmailForwards ) ? [ 'Duplicated' ] : []; | ||
} ); | ||
} | ||
|
||
function validateField( { name, value } ) { | ||
switch ( name ) { | ||
case 'mailbox': | ||
return /^[a-z0-9._+-]{1,64}$/i.test( value ) && ! /(^\.)|(\.{2,})|(\.$)/.test( value ); | ||
case 'destination': | ||
return emailValidator.validate( value ); | ||
default: | ||
return true; | ||
} | ||
} | ||
|
||
export { getEmailForwardsCount } from './get-email-forwards-count'; | ||
export { hasEmailForwards } from './has-email-forwards'; | ||
export { getDomainsWithEmailForwards } from './get-domains-with-email-forwards'; | ||
export { validateAllFields }; |
80 changes: 0 additions & 80 deletions
80
client/my-sites/email/email-forwarding/actions-menu/index.tsx
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
client/my-sites/email/email-forwarding/actions-menu/style.scss
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.