Add MailerLog error reset on successful authorization email validation
[MAILPOET-2022]
This commit is contained in:
committed by
M. Shull
parent
01dcdd0262
commit
61c3630add
@@ -3,6 +3,8 @@
|
||||
namespace MailPoet\Services;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use MailPoet\Mailer\MailerError;
|
||||
use MailPoet\Mailer\MailerLog;
|
||||
use MailPoet\Models\Newsletter;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
|
||||
@@ -27,6 +29,7 @@ class AuthorizedEmailsController {
|
||||
$authorized_emails_release_date = new Carbon('2019-03-06');
|
||||
if (!Bridge::isMPSendingServiceEnabled() || $installed_at < $authorized_emails_release_date) {
|
||||
$this->settings->set(self::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING, null);
|
||||
$this->updateMailerLog();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -41,6 +44,7 @@ class AuthorizedEmailsController {
|
||||
$result = $this->validateAddressesInSettings($authorized_emails, $result);
|
||||
$result = $this->validateAddressesInScheduledAndAutomaticEmails($authorized_emails, $result);
|
||||
$this->settings->set(self::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING, $result ?: null);
|
||||
$this->updateMailerLog($result);
|
||||
}
|
||||
|
||||
function onSettingsSave($settings) {
|
||||
@@ -96,6 +100,19 @@ class AuthorizedEmailsController {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $error
|
||||
*/
|
||||
private function updateMailerLog(array $error = null) {
|
||||
if ($error) {
|
||||
return;
|
||||
}
|
||||
$mailer_log_error = MailerLog::getError();
|
||||
if ($mailer_log_error && $mailer_log_error['operation'] === MailerError::OPERATION_AUTHORIZATION) {
|
||||
MailerLog::resumeSending();
|
||||
}
|
||||
}
|
||||
|
||||
private function validateAuthorizedEmail($authorized_emails, $email) {
|
||||
return in_array(strtolower($email), $authorized_emails, true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user