Refactor mailer blacklist from trait to DI [MAILPOET-2208]
This commit is contained in:
@ -3,14 +3,13 @@
|
||||
namespace MailPoet\Mailer\Methods;
|
||||
|
||||
use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Mailer\Methods\Common\BlacklistCheck;
|
||||
use MailPoet\Mailer\Methods\ErrorMappers\SendGridMapper;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class SendGrid {
|
||||
use BlacklistTrait;
|
||||
|
||||
public $url = 'https://api.sendgrid.com/api/mail.send.json';
|
||||
public $api_key;
|
||||
public $sender;
|
||||
@ -19,6 +18,9 @@ class SendGrid {
|
||||
/** @var SendGridMapper */
|
||||
private $error_mapper;
|
||||
|
||||
/** @var BlacklistCheck */
|
||||
private $blacklist;
|
||||
|
||||
private $wp;
|
||||
|
||||
function __construct($api_key, $sender, $reply_to, SendGridMapper $error_mapper) {
|
||||
@ -27,10 +29,11 @@ class SendGrid {
|
||||
$this->reply_to = $reply_to;
|
||||
$this->error_mapper = $error_mapper;
|
||||
$this->wp = new WPFunctions();
|
||||
$this->blacklist = new BlacklistCheck();
|
||||
}
|
||||
|
||||
function send($newsletter, $subscriber, $extra_params = []) {
|
||||
if ($this->isBlacklisted($subscriber)) {
|
||||
if ($this->blacklist->isBlacklisted($subscriber)) {
|
||||
$error = $this->error_mapper->getBlacklistError($subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
}
|
||||
|
Reference in New Issue
Block a user