Fixes sending limit not being enforced when email frequency limit is
changed to a lesser value OR when it is changed while sending is in progress
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
namespace MailPoet\API\Endpoints;
|
||||
|
||||
use MailPoet\API\Endpoint as APIEndpoint;
|
||||
use MailPoet\API\Error as APIError;
|
||||
use MailPoet\Mailer\Mailer as MailerConfig;
|
||||
use MailPoet\Models\Setting;
|
||||
use MailPoet\Services\Bridge;
|
||||
|
||||
@ -16,20 +18,20 @@ class Settings extends APIEndpoint {
|
||||
if(empty($settings)) {
|
||||
return $this->badRequest(array(
|
||||
APIError::BAD_REQUEST =>
|
||||
__("You have not specified any settings to be saved.", 'mailpoet')
|
||||
__('You have not specified any settings to be saved.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
foreach($settings as $name => $value) {
|
||||
Setting::setValue($name, $value);
|
||||
}
|
||||
if(!empty($settings['mta']['mailpoet_api_key'])
|
||||
if(!empty($settings[MailerConfig::MAILER_CONFIG_SETTING_NAME]['mailpoet_api_key'])
|
||||
&& Bridge::isMPSendingServiceEnabled()
|
||||
) {
|
||||
$bridge = new Bridge();
|
||||
$result = $bridge->checkKey($settings['mta']['mailpoet_api_key']);
|
||||
$result = $bridge->checkKey($settings[MailerConfig::MAILER_CONFIG_SETTING_NAME]['mailpoet_api_key']);
|
||||
$bridge->updateSubscriberCount($result);
|
||||
}
|
||||
return $this->successResponse(Setting::getAll());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user