Pause sending of spammer users [MAILPOET-1649]

This commit is contained in:
Amine Ben hammou
2018-11-28 17:33:26 +01:00
parent ddaf9e361d
commit 160d4ae3ec
4 changed files with 32 additions and 1 deletions

View File

@ -410,9 +410,11 @@ const MailerMixin = {
mailerErrorNotice += ` ${MailPoet.I18n.t('mailerErrorCode')
.replace('%$1s', state.meta.mta_log.error.error_code)}`;
}
// eslint-disable-next-line react/no-danger
mailerErrorNotice = <p dangerouslySetInnerHTML={{ __html: mailerErrorNotice }} />;
return (
<div>
<p>{ mailerErrorNotice }</p>
{ mailerErrorNotice }
<p>{ mailerCheckSettingsNotice }</p>
<p>
<a

View File

@ -5,6 +5,7 @@ use MailPoet\Mailer\MailerError;
use MailPoet\Mailer\SubscriberError;
use MailPoet\Services\Bridge\API;
use InvalidArgumentException;
use MailPoet\Util\Helpers;
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');
$retry_interval = self::TEMPORARY_UNAVAILABLE_RETRY_INTERVAL;
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_PAYLOAD_TOO_BIG:
default:

View File

@ -20,6 +20,7 @@ class API {
const RESPONSE_CODE_NOT_ARRAY = 422;
const RESPONSE_CODE_PAYLOAD_TOO_BIG = 413;
const RESPONSE_CODE_PAYLOAD_ERROR = 400;
const RESPONSE_CODE_BANNED_ACCOUNT = 403;
private $api_key;
@ -85,6 +86,7 @@ class API {
'message' => $result->get_error_message()
);
}
$response_code = WPFunctions::wpRemoteRetrieveResponseCode($result);
if($response_code !== 201) {
$response = (WPFunctions::wpRemoteRetrieveBody($result)) ?

View File

@ -4,6 +4,7 @@ namespace MailPoet\Test\Mailer\Methods\ErrorMappers;
use MailPoet\Mailer\MailerError;
use MailPoet\Mailer\Methods\ErrorMappers\MailPoetMapper;
use MailPoet\Services\Bridge\API;
use MailPoet\Util\Helpers;
class MailPoetMapperTest extends \MailPoetTest {
/** @var MailPoetMapper */
@ -39,6 +40,24 @@ class MailPoetMapperTest extends \MailPoetTest {
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() {
$api_result = [
'code' => API::RESPONSE_CODE_PAYLOAD_TOO_BIG,