Only send email, as per plugin spec
This commit is contained in:
parent
3eb7d43d74
commit
76f4cfe4ce
1 changed files with 4 additions and 6 deletions
|
@ -212,22 +212,20 @@ class LBRY_Admin
|
||||||
// COMBAK: Check user permissions possibly
|
// COMBAK: Check user permissions possibly
|
||||||
public static function wallet_balance_warning()
|
public static function wallet_balance_warning()
|
||||||
{
|
{
|
||||||
if (!get_transient('lbry_wallet_warning')) {
|
// See if we've checked in the past two hours
|
||||||
|
if (!get_transient('lbry_wallet_check')) {
|
||||||
$balance = LBRY()->daemon->wallet_balance();
|
$balance = LBRY()->daemon->wallet_balance();
|
||||||
if ($balance < LBRY_MIN_BALANCE) {
|
if ($balance < LBRY_MIN_BALANCE) {
|
||||||
|
// If LBRY Balance is low, send email, but only once per day
|
||||||
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 " . 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.';
|
$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, DAY_IN_SECONDS);
|
set_transient('lbry_wallet_warning_email', true, DAY_IN_SECONDS);
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
set_transient('lbry_wallet_check', true, 2 * HOUR_IN_SECONDS);
|
||||||
set_transient('lbry_wallet_warning', true, 2 * HOUR_IN_SECONDS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue