Add isPartiallyVerifiedDomain to SenderField

And show the SenderDomainWarning by default.

[MAILPOET-5782]
This commit is contained in:
Brezo Cordero
2024-01-05 21:46:29 -06:00
committed by Aschepikov
parent a4905d0f61
commit cfb3304186

View File

@@ -10,14 +10,18 @@ import {
validateField, validateField,
} from 'common/functions/parsley-helper-functions'; } from 'common/functions/parsley-helper-functions';
import { extractEmailDomain } from 'common/functions'; import { extractEmailDomain } from 'common/functions';
import { checkSenderEmailDomainDmarcPolicy } from 'common/check-sender-domain-dmarc-policy';
class SenderField extends Component { class SenderField extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
const emailDomain = extractEmailDomain(props.item.sender_address);
this.state = { this.state = {
emailAddress: props.item.sender_address, emailAddress: props.item.sender_address,
showSenderDomainWarning: false, showSenderDomainWarning:
!window.mailpoet_verified_sender_domains.includes(emailDomain),
isPartiallyVerifiedDomain:
window.mailpoet_partially_verified_sender_domains.includes(emailDomain),
showAuthEmailsError: false, showAuthEmailsError: false,
}; };
this.onChange = this.onChange.bind(this); this.onChange = this.onChange.bind(this);
@@ -107,17 +111,12 @@ class SenderField extends Component {
this.showSenderFieldError(emailAddressIsAuthorized, emailAddress); this.showSenderFieldError(emailAddressIsAuthorized, emailAddress);
// Skip domain DMARC validation if the email is a freemail this.setState({
const isFreeDomain = MailPoet.freeMailDomains.indexOf(emailDomain) > -1; isPartiallyVerifiedDomain:
if (isFreeDomain) return; window.mailpoet_partially_verified_sender_domains.includes(emailDomain),
});
checkSenderEmailDomainDmarcPolicy(emailAddress) this.showSenderDomainError(true, emailAddress);
.then((status) => {
this.showSenderDomainError(status, emailAddress);
})
.catch(() => {
// do nothing for now when the request fails
});
} }
render() { render() {
@@ -142,6 +141,7 @@ class SenderField extends Component {
this.state.showSenderDomainWarning && this.state.showSenderDomainWarning &&
!this.state.showAuthEmailsError !this.state.showAuthEmailsError
} }
isPartiallyVerifiedDomain={this.state.isPartiallyVerifiedDomain}
onSuccessfulEmailOrDomainAuthorization={(data) => { onSuccessfulEmailOrDomainAuthorization={(data) => {
if (data.type === 'email') { if (data.type === 'email') {
this.setState({ showAuthEmailsError: false }); this.setState({ showAuthEmailsError: false });
@@ -153,6 +153,7 @@ class SenderField extends Component {
} }
if (data.type === 'domain') { if (data.type === 'domain') {
this.setState({ showSenderDomainWarning: false }); this.setState({ showSenderDomainWarning: false });
this.setState({ isPartiallyVerifiedDomain: false });
MailPoet.trackEvent('MSS in plugin verify sender domain', { MailPoet.trackEvent('MSS in plugin verify sender domain', {
'verify sender domain source': 'newsletter', 'verify sender domain source': 'newsletter',