Adjust the unsubscribe key to use the new structure

[MAILPOET-4702]
This commit is contained in:
Sam Najian
2022-11-01 17:23:39 +01:00
committed by Aschepikov
parent e3539b06a2
commit c39ae1fe1f

View File

@ -10,6 +10,7 @@ use MailPoet\Mailer\Methods\ErrorMappers\MailPoetMapper;
use MailPoet\Services\AuthorizedEmailsController; use MailPoet\Services\AuthorizedEmailsController;
use MailPoet\Services\Bridge; use MailPoet\Services\Bridge;
use MailPoet\Services\Bridge\API; use MailPoet\Services\Bridge\API;
use MailPoet\Util\Url as UrlUtil;
class MailPoet implements MailerMethod { class MailPoet implements MailerMethod {
public $api; public $api;
@ -26,12 +27,16 @@ class MailPoet implements MailerMethod {
/** @var BlacklistCheck */ /** @var BlacklistCheck */
private $blacklist; private $blacklist;
/*** @var UrlUtil */
private $urlUtil;
public function __construct( public function __construct(
$apiKey, $apiKey,
$sender, $sender,
$replyTo, $replyTo,
MailPoetMapper $errorMapper, MailPoetMapper $errorMapper,
AuthorizedEmailsController $authorizedEmailsController AuthorizedEmailsController $authorizedEmailsController,
UrlUtil $urlUtil
) { ) {
$this->api = new API($apiKey); $this->api = new API($apiKey);
$this->sender = $sender; $this->sender = $sender;
@ -40,6 +45,7 @@ class MailPoet implements MailerMethod {
$this->errorMapper = $errorMapper; $this->errorMapper = $errorMapper;
$this->authorizedEmailsController = $authorizedEmailsController; $this->authorizedEmailsController = $authorizedEmailsController;
$this->blacklist = new BlacklistCheck(); $this->blacklist = new BlacklistCheck();
$this->urlUtil = $urlUtil;
} }
public function send($newsletter, $subscriber, $extraParams = []): array { public function send($newsletter, $subscriber, $extraParams = []): array {
@ -144,7 +150,10 @@ class MailPoet implements MailerMethod {
$body['text'] = $newsletter['body']['text']; $body['text'] = $newsletter['body']['text'];
} }
if ($unsubscribeUrl) { if ($unsubscribeUrl) {
$body['list_unsubscribe'] = $unsubscribeUrl; $body['unsubscribe'] = [
'url' => $unsubscribeUrl,
'post' => $this->urlUtil->isUsingHttps($unsubscribeUrl),
];
} }
if ($meta) { if ($meta) {
$body['meta'] = $meta; $body['meta'] = $meta;