Send email warning once a day. Check and post admin warning once an hour
This commit is contained in:
parent
0bf3fd82a5
commit
3eb7d43d74
3 changed files with 6 additions and 7 deletions
|
@ -209,8 +209,7 @@ class LBRY_Admin
|
||||||
/**
|
/**
|
||||||
* Checks at most once an hour to see if the wallet balance is too low
|
* Checks at most once an hour to see if the wallet balance is too low
|
||||||
*/
|
*/
|
||||||
// COMBAK: Check user permissions possibly, figure out proper timing Interval, Email warning
|
// COMBAK: Check user permissions possibly
|
||||||
// TODO: make sure it doesn't set a bunch of warnings
|
|
||||||
public static function wallet_balance_warning()
|
public static function wallet_balance_warning()
|
||||||
{
|
{
|
||||||
if (!get_transient('lbry_wallet_warning')) {
|
if (!get_transient('lbry_wallet_warning')) {
|
||||||
|
@ -219,16 +218,16 @@ class LBRY_Admin
|
||||||
if (!get_transient('lbry_wallet_warning_email')) {
|
if (!get_transient('lbry_wallet_warning_email')) {
|
||||||
$email = get_option('admin_email');
|
$email = get_option('admin_email');
|
||||||
$subject = 'Your LBRYPress Wallet Balance is Low!';
|
$subject = 'Your LBRYPress Wallet Balance is Low!';
|
||||||
$message = 'You LBRY Wallet for your wordpress installation at ' . get_option('site_url') . 'is running very low. In order to keep publishing to the LBRY network, please add some LBC to your account.';
|
$message = "You LBRY Wallet for your wordpress installation at " . site_url() . " is running very low.\r\n\r\nYou currently have " . $balance . ' LBC left in your wallet. In order to keep publishing to the LBRY network, please add some LBC to your account.';
|
||||||
wp_mail($email, $subject, $message);
|
wp_mail($email, $subject, $message);
|
||||||
set_transient('lbry_wallet_warning_email', true, 30);
|
set_transient('lbry_wallet_warning_email', true, DAY_IN_SECONDS);
|
||||||
// TODO: Fix outgoing email
|
// TODO: Fix outgoing email
|
||||||
}
|
}
|
||||||
|
|
||||||
LBRY()->notice->set_notice('error', 'Your account balance is low, please add LBC to your account to continue publishing to the LBRY Network', true);
|
LBRY()->notice->set_notice('error', 'Your account balance is low, please add LBC to your account to continue publishing to the LBRY Network', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_transient('lbry_wallet_warning', true, 30);
|
set_transient('lbry_wallet_warning', true, 2 * HOUR_IN_SECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class LBRY_Admin_Notice
|
||||||
/**
|
/**
|
||||||
* Sets transients for admin errors
|
* Sets transients for admin errors
|
||||||
*/
|
*/
|
||||||
// TODO: Make sure we only set one transient at a time
|
// TODO: Make sure we only set one transient at a time per error
|
||||||
public function set_notice($status = 'error', $message = 'Something went wrong', $is_dismissible = false)
|
public function set_notice($status = 'error', $message = 'Something went wrong', $is_dismissible = false)
|
||||||
{
|
{
|
||||||
$notice = array(
|
$notice = array(
|
||||||
|
|
|
@ -108,7 +108,7 @@ class LBRYPress
|
||||||
'license2' => 'License 2',
|
'license2' => 'License 2',
|
||||||
'license3' => 'License 3'
|
'license3' => 'License 3'
|
||||||
));
|
));
|
||||||
$this->define('LBRY_MIN_BALANCE', 2000);
|
$this->define('LBRY_MIN_BALANCE', 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue