Display a specific error message for banned users

[MAILPOET-3667]
This commit is contained in:
Jan Lysý
2021-09-11 12:15:17 +02:00
committed by Veljko V
parent 2619f9cdda
commit 7f15fce246
4 changed files with 66 additions and 13 deletions

View File

@ -73,6 +73,28 @@ const MailerError = (props) => {
() => <br key={`br-${brKey++}`} /> // eslint-disable-line no-plusplus
);
if (props.mta_log.error.operation === 'insufficient_privileges') {
return (
<div className="mailpoet_notice notice notice-error">
<p>
{ message }
</p>
<p>
<a
href="#"
className="button button-primary"
onClick={(event) => {
event.preventDefault();
resumeMailerSending(event);
}}
>
{ MailPoet.I18n.t('mailerResumeSendingAfterUpgradeButton') }
</a>
</p>
</div>
);
}
return (
<div className="mailpoet_notice notice notice-error">
<p>

View File

@ -8,10 +8,13 @@ class MailerError {
const OPERATION_CONNECT = 'connect';
const OPERATION_SEND = 'send';
const OPERATION_AUTHORIZATION = 'authorization';
const OPERATION_INSUFFICIENT_PRIVILEGES = 'insufficient_privileges';
const LEVEL_HARD = 'hard';
const LEVEL_SOFT = 'soft';
const MESSAGE_EMAIL_FORBIDDEN_ACTION = 'Key is valid, but the action is forbidden';
const MESSAGE_EMAIL_INSUFFICIENT_PRIVILEGES = 'Insufficient privileges';
const MESSAGE_EMAIL_NOT_AUTHORIZED = 'The email address is not authorized';
/** @var string */

View File

@ -56,7 +56,10 @@ class MailPoetMapper {
$retryInterval = self::TEMPORARY_UNAVAILABLE_RETRY_INTERVAL;
break;
case API::RESPONSE_CODE_CAN_NOT_SEND:
if ($result['message'] === MailerError::MESSAGE_EMAIL_NOT_AUTHORIZED) {
if ($result['message'] === MailerError::MESSAGE_EMAIL_INSUFFICIENT_PRIVILEGES) {
$operation = MailerError::OPERATION_INSUFFICIENT_PRIVILEGES;
$message = $this->getInsufficientPrivilegesMessage();
} elseif ($result['message'] === MailerError::MESSAGE_EMAIL_NOT_AUTHORIZED) {
$operation = MailerError::OPERATION_AUTHORIZATION;
$message = $this->getUnauthorizedEmailMessage($sender);
} else {
@ -108,27 +111,51 @@ class MailPoetMapper {
return $message;
}
private function getAccountBannedMessage() {
$message = WPFunctions::get()->__('The MailPoet Sending Service has stopped sending your emails for one of the following reasons:', 'mailpoet');
$subscriberLimitMessage = Helpers::replaceLinkTags(
WPFunctions::get()->__('You may have reached the subscriber limit of your plan. [link]Manage your subscriptions[/link].', 'mailpoet'),
'https://account.mailpoet.com/account',
private function getInsufficientPrivilegesMessage(): string {
$message = __('You have reached the subscriber limit of your plan. Please [link1]upgrade your plan[/link1], or [link2]contact our support team[/link2] if you have any questions.', 'mailpoet');
$message = Helpers::replaceLinkTags(
$message,
'https://account.mailpoet.com/account/',
[
'target' => '_blank',
'rel' => 'noopener noreferrer',
]
],
'link1'
);
$deliverabilityMessage = Helpers::replaceLinkTags(
WPFunctions::get()->__('You may have had a poor deliverability rate. Please [link]contact our support team[/link] to resolve the issue.', 'mailpoet'),
$message = Helpers::replaceLinkTags(
$message,
'https://www.mailpoet.com/support/',
[
'target' => '_blank',
'rel' => 'noopener noreferrer',
]
],
'link2'
);
return "$message<br><br>$subscriberLimitMessage<br>$deliverabilityMessage<br>";
return "{$message}<br/>";
}
private function getAccountBannedMessage(): string {
$message = __('MailPoet Sending Service has been temporarily suspended for your site due to [link1]degraded email deliverability[/link1]. Please [link2]contact our support team[/link2] to resolve the issue.', 'mailpoet');
$message = Helpers::replaceLinkTags(
$message,
'https://kb.mailpoet.com/article/231-sending-does-not-work#suspended',
[
'target' => '_blank',
'rel' => 'noopener noreferrer',
],
'link1'
);
$message = Helpers::replaceLinkTags(
$message,
'https://www.mailpoet.com/support/',
[
'target' => '_blank',
'rel' => 'noopener noreferrer',
],
'link2'
);
return "{$message}<br/>";
}
}

View File

@ -333,6 +333,7 @@
'mailerErrorCode': __('Error code: %$1s'),
'mailerCheckSettingsNotice': __('Check your [link]sending method settings[/link].'),
'mailerResumeSendingButton': __('Resume sending'),
'mailerResumeSendingAfterUpgradeButton': __('I have upgraded my subscription, resume sending'),
'confirmEdit': __('Sending is in progress. Do you want to pause sending and edit the newsletter?'),
'confirmTitle': __('Confirm to proceed'),
'confirmLabel': __('Confirm'),