Recheck keys and update subscribers limit
[MAILPOET-2396]
This commit is contained in:
committed by
Jack Kitterhing
parent
55f8626493
commit
fa961d27b8
@ -12,9 +12,15 @@ const SubscribersLimitNotice = () => {
|
|||||||
const upgradeLink = hasKey
|
const upgradeLink = hasKey
|
||||||
? 'https://account.mailpoet.com/upgrade'
|
? 'https://account.mailpoet.com/upgrade'
|
||||||
: `https://account.mailpoet.com/?s=${window.mailpoet_subscribers_count + 1}`;
|
: `https://account.mailpoet.com/?s=${window.mailpoet_subscribers_count + 1}`;
|
||||||
const refreshSubscribers = () => {
|
const refreshSubscribers = async () => {
|
||||||
console.log('Refresh subscribers ...');
|
await MailPoet.Ajax.post({
|
||||||
|
api_version: window.mailpoet_api_version,
|
||||||
|
endpoint: 'services',
|
||||||
|
action: 'recheckKeys',
|
||||||
|
});
|
||||||
|
window.location.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Notice type="error" timeout={false} closable={false}>
|
<Notice type="error" timeout={false} closable={false}>
|
||||||
<h3>{title}</h3>
|
<h3>{title}</h3>
|
||||||
@ -33,13 +39,16 @@ const SubscribersLimitNotice = () => {
|
|||||||
{MailPoet.I18n.t('upgradeNow')}
|
{MailPoet.I18n.t('upgradeNow')}
|
||||||
</a>
|
</a>
|
||||||
{hasKey && (
|
{hasKey && (
|
||||||
|
<>
|
||||||
|
{' '}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="button button-primary"
|
className="button"
|
||||||
onClick={refreshSubscribers}
|
onClick={refreshSubscribers}
|
||||||
>
|
>
|
||||||
{MailPoet.I18n.t('refreshMySubscribers')}
|
{MailPoet.I18n.t('refreshMySubscribers')}
|
||||||
</button>
|
</button>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
</Notice>
|
</Notice>
|
||||||
|
@ -7,6 +7,8 @@ use MailPoet\API\JSON\Endpoint as APIEndpoint;
|
|||||||
use MailPoet\API\JSON\Error as APIError;
|
use MailPoet\API\JSON\Error as APIError;
|
||||||
use MailPoet\Config\AccessControl;
|
use MailPoet\Config\AccessControl;
|
||||||
use MailPoet\Config\Installer;
|
use MailPoet\Config\Installer;
|
||||||
|
use MailPoet\Cron\Workers\KeyCheck\PremiumKeyCheck;
|
||||||
|
use MailPoet\Cron\Workers\KeyCheck\SendingServiceKeyCheck;
|
||||||
use MailPoet\Services\Bridge;
|
use MailPoet\Services\Bridge;
|
||||||
use MailPoet\Services\SPFCheck;
|
use MailPoet\Services\SPFCheck;
|
||||||
use MailPoet\Settings\SettingsController;
|
use MailPoet\Settings\SettingsController;
|
||||||
@ -29,15 +31,23 @@ class Services extends APIEndpoint {
|
|||||||
/** @var DateTime */
|
/** @var DateTime */
|
||||||
public $date_time;
|
public $date_time;
|
||||||
|
|
||||||
|
/** @var SendingServiceKeyCheck */
|
||||||
|
private $mss_worker;
|
||||||
|
|
||||||
|
/** @var PremiumKeyCheck */
|
||||||
|
private $premium_worker;
|
||||||
|
|
||||||
public $permissions = [
|
public $permissions = [
|
||||||
'global' => AccessControl::PERMISSION_MANAGE_SETTINGS,
|
'global' => AccessControl::PERMISSION_MANAGE_SETTINGS,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(Bridge $bridge, SettingsController $settings, AnalyticsHelper $analytics, SPFCheck $spf_check) {
|
public function __construct(Bridge $bridge, SettingsController $settings, AnalyticsHelper $analytics, SPFCheck $spf_check, SendingServiceKeyCheck $mss_worker, PremiumKeyCheck $premium_worker) {
|
||||||
$this->bridge = $bridge;
|
$this->bridge = $bridge;
|
||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
$this->analytics = $analytics;
|
$this->analytics = $analytics;
|
||||||
$this->spf_check = $spf_check;
|
$this->spf_check = $spf_check;
|
||||||
|
$this->mss_worker = $mss_worker;
|
||||||
|
$this->premium_worker = $premium_worker;
|
||||||
$this->date_time = new DateTime();
|
$this->date_time = new DateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,6 +189,14 @@ class Services extends APIEndpoint {
|
|||||||
return $this->errorResponse([APIError::BAD_REQUEST => $error]);
|
return $this->errorResponse([APIError::BAD_REQUEST => $error]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function recheckKeys() {
|
||||||
|
$this->mss_worker->init();
|
||||||
|
$this->mss_worker->checkKey();
|
||||||
|
$this->premium_worker->init();
|
||||||
|
$this->premium_worker->checkKey();
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
private function getErrorDescriptionByCode($code) {
|
private function getErrorDescriptionByCode($code) {
|
||||||
switch ($code) {
|
switch ($code) {
|
||||||
case Bridge::CHECK_ERROR_UNAVAILABLE:
|
case Bridge::CHECK_ERROR_UNAVAILABLE:
|
||||||
|
@ -8,6 +8,8 @@ use MailPoet\Analytics\Analytics;
|
|||||||
use MailPoet\API\JSON\Response as APIResponse;
|
use MailPoet\API\JSON\Response as APIResponse;
|
||||||
use MailPoet\API\JSON\v1\Services;
|
use MailPoet\API\JSON\v1\Services;
|
||||||
use MailPoet\Config\Installer;
|
use MailPoet\Config\Installer;
|
||||||
|
use MailPoet\Cron\Workers\KeyCheck\PremiumKeyCheck;
|
||||||
|
use MailPoet\Cron\Workers\KeyCheck\SendingServiceKeyCheck;
|
||||||
use MailPoet\Services\Bridge;
|
use MailPoet\Services\Bridge;
|
||||||
use MailPoet\Services\SPFCheck;
|
use MailPoet\Services\SPFCheck;
|
||||||
use MailPoet\Settings\SettingsController;
|
use MailPoet\Settings\SettingsController;
|
||||||
@ -404,7 +406,9 @@ class ServicesTest extends \MailPoetTest {
|
|||||||
$this->di_container->get(Bridge::class),
|
$this->di_container->get(Bridge::class),
|
||||||
$this->di_container->get(SettingsController::class),
|
$this->di_container->get(SettingsController::class),
|
||||||
$this->di_container->get(Analytics::class),
|
$this->di_container->get(Analytics::class),
|
||||||
$spf_check
|
$spf_check,
|
||||||
|
$this->di_container->get(SendingServiceKeyCheck::class),
|
||||||
|
$this->di_container->get(PremiumKeyCheck::class)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +417,9 @@ class ServicesTest extends \MailPoetTest {
|
|||||||
$bridge,
|
$bridge,
|
||||||
$this->di_container->get(SettingsController::class),
|
$this->di_container->get(SettingsController::class),
|
||||||
$this->di_container->get(Analytics::class),
|
$this->di_container->get(Analytics::class),
|
||||||
$this->di_container->get(SPFCheck::class)
|
$this->di_container->get(SPFCheck::class),
|
||||||
|
$this->di_container->get(SendingServiceKeyCheck::class),
|
||||||
|
$this->di_container->get(PremiumKeyCheck::class)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user