Pause sending of spammer users [MAILPOET-1649]
This commit is contained in:
@ -410,9 +410,11 @@ const MailerMixin = {
|
|||||||
mailerErrorNotice += ` ${MailPoet.I18n.t('mailerErrorCode')
|
mailerErrorNotice += ` ${MailPoet.I18n.t('mailerErrorCode')
|
||||||
.replace('%$1s', state.meta.mta_log.error.error_code)}`;
|
.replace('%$1s', state.meta.mta_log.error.error_code)}`;
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line react/no-danger
|
||||||
|
mailerErrorNotice = <p dangerouslySetInnerHTML={{ __html: mailerErrorNotice }} />;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<p>{ mailerErrorNotice }</p>
|
{ mailerErrorNotice }
|
||||||
<p>{ mailerCheckSettingsNotice }</p>
|
<p>{ mailerCheckSettingsNotice }</p>
|
||||||
<p>
|
<p>
|
||||||
<a
|
<a
|
||||||
|
@ -5,6 +5,7 @@ use MailPoet\Mailer\MailerError;
|
|||||||
use MailPoet\Mailer\SubscriberError;
|
use MailPoet\Mailer\SubscriberError;
|
||||||
use MailPoet\Services\Bridge\API;
|
use MailPoet\Services\Bridge\API;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
use MailPoet\Util\Helpers;
|
||||||
|
|
||||||
if(!defined('ABSPATH')) exit;
|
if(!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
@ -49,6 +50,13 @@ class MailPoetMapper {
|
|||||||
$message = __('Email service is temporarily not available, please try again in a few minutes.', 'mailpoet');
|
$message = __('Email service is temporarily not available, please try again in a few minutes.', 'mailpoet');
|
||||||
$retry_interval = self::TEMPORARY_UNAVAILABLE_RETRY_INTERVAL;
|
$retry_interval = self::TEMPORARY_UNAVAILABLE_RETRY_INTERVAL;
|
||||||
break;
|
break;
|
||||||
|
case API::RESPONSE_CODE_BANNED_ACCOUNT:
|
||||||
|
$message = Helpers::replaceLinkTags(
|
||||||
|
__('You currently are not permitted to send any emails with MailPoet Sending Service, which may have happened due to poor deliverability. Please [link]contact our support team[/link] to resolve the issue.', 'mailpoet'),
|
||||||
|
'https://www.mailpoet.com/support/',
|
||||||
|
array('target' => '_blank')
|
||||||
|
);
|
||||||
|
break;
|
||||||
case API::RESPONSE_CODE_KEY_INVALID:
|
case API::RESPONSE_CODE_KEY_INVALID:
|
||||||
case API::RESPONSE_CODE_PAYLOAD_TOO_BIG:
|
case API::RESPONSE_CODE_PAYLOAD_TOO_BIG:
|
||||||
default:
|
default:
|
||||||
|
@ -20,6 +20,7 @@ class API {
|
|||||||
const RESPONSE_CODE_NOT_ARRAY = 422;
|
const RESPONSE_CODE_NOT_ARRAY = 422;
|
||||||
const RESPONSE_CODE_PAYLOAD_TOO_BIG = 413;
|
const RESPONSE_CODE_PAYLOAD_TOO_BIG = 413;
|
||||||
const RESPONSE_CODE_PAYLOAD_ERROR = 400;
|
const RESPONSE_CODE_PAYLOAD_ERROR = 400;
|
||||||
|
const RESPONSE_CODE_BANNED_ACCOUNT = 403;
|
||||||
|
|
||||||
private $api_key;
|
private $api_key;
|
||||||
|
|
||||||
@ -85,6 +86,7 @@ class API {
|
|||||||
'message' => $result->get_error_message()
|
'message' => $result->get_error_message()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$response_code = WPFunctions::wpRemoteRetrieveResponseCode($result);
|
$response_code = WPFunctions::wpRemoteRetrieveResponseCode($result);
|
||||||
if($response_code !== 201) {
|
if($response_code !== 201) {
|
||||||
$response = (WPFunctions::wpRemoteRetrieveBody($result)) ?
|
$response = (WPFunctions::wpRemoteRetrieveBody($result)) ?
|
||||||
|
@ -4,6 +4,7 @@ namespace MailPoet\Test\Mailer\Methods\ErrorMappers;
|
|||||||
use MailPoet\Mailer\MailerError;
|
use MailPoet\Mailer\MailerError;
|
||||||
use MailPoet\Mailer\Methods\ErrorMappers\MailPoetMapper;
|
use MailPoet\Mailer\Methods\ErrorMappers\MailPoetMapper;
|
||||||
use MailPoet\Services\Bridge\API;
|
use MailPoet\Services\Bridge\API;
|
||||||
|
use MailPoet\Util\Helpers;
|
||||||
|
|
||||||
class MailPoetMapperTest extends \MailPoetTest {
|
class MailPoetMapperTest extends \MailPoetTest {
|
||||||
/** @var MailPoetMapper */
|
/** @var MailPoetMapper */
|
||||||
@ -39,6 +40,24 @@ class MailPoetMapperTest extends \MailPoetTest {
|
|||||||
expect($error->getMessage())->equals('JSON input is not an array');
|
expect($error->getMessage())->equals('JSON input is not an array');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testGetErrorBannedAccount() {
|
||||||
|
$api_result = [
|
||||||
|
'code' => API::RESPONSE_CODE_BANNED_ACCOUNT,
|
||||||
|
'status' => API::SENDING_STATUS_SEND_ERROR,
|
||||||
|
'message' => 'this is a spam',
|
||||||
|
];
|
||||||
|
$error = $this->mapper->getErrorForResult($api_result, $this->subscribers);
|
||||||
|
|
||||||
|
expect($error)->isInstanceOf(MailerError::class);
|
||||||
|
expect($error->getOperation())->equals(MailerError::OPERATION_SEND);
|
||||||
|
expect($error->getLevel())->equals(MailerError::LEVEL_HARD);
|
||||||
|
expect($error->getMessage())->equals(Helpers::replaceLinkTags(
|
||||||
|
__('You currently are not permitted to send any emails with MailPoet Sending Service, which may have happened due to poor deliverability. Please [link]contact our support team[/link] to resolve the issue.', 'mailpoet'),
|
||||||
|
'https://www.mailpoet.com/support/',
|
||||||
|
array('target' => '_blank')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
function testGetErrorPayloadTooBig() {
|
function testGetErrorPayloadTooBig() {
|
||||||
$api_result = [
|
$api_result = [
|
||||||
'code' => API::RESPONSE_CODE_PAYLOAD_TOO_BIG,
|
'code' => API::RESPONSE_CODE_PAYLOAD_TOO_BIG,
|
||||||
|
Reference in New Issue
Block a user