Fix monero subscription extension bug
This commit is contained in:
parent
982a8e8bc2
commit
44aebf989a
1 changed files with 4 additions and 1 deletions
|
@ -139,7 +139,6 @@ pub async fn check_monero_subscriptions(
|
||||||
let duration_secs = (payout_amount.as_pico() / payment_info.price)
|
let duration_secs = (payout_amount.as_pico() / payment_info.price)
|
||||||
.try_into()
|
.try_into()
|
||||||
.map_err(|_| MoneroError::OtherError("invalid duration"))?;
|
.map_err(|_| MoneroError::OtherError("invalid duration"))?;
|
||||||
let expires_at = Utc::now() + Duration::seconds(duration_secs);
|
|
||||||
|
|
||||||
set_invoice_status(
|
set_invoice_status(
|
||||||
db_client,
|
db_client,
|
||||||
|
@ -159,6 +158,9 @@ pub async fn check_monero_subscriptions(
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
// Update subscription expiration date
|
// Update subscription expiration date
|
||||||
|
let expires_at =
|
||||||
|
std::cmp::max(subscription.expires_at, Utc::now()) +
|
||||||
|
Duration::seconds(duration_secs);
|
||||||
update_subscription(
|
update_subscription(
|
||||||
db_client,
|
db_client,
|
||||||
subscription.id,
|
subscription.id,
|
||||||
|
@ -180,6 +182,7 @@ pub async fn check_monero_subscriptions(
|
||||||
},
|
},
|
||||||
Err(DatabaseError::NotFound(_)) => {
|
Err(DatabaseError::NotFound(_)) => {
|
||||||
// New subscription
|
// New subscription
|
||||||
|
let expires_at = Utc::now() + Duration::seconds(duration_secs);
|
||||||
create_subscription(
|
create_subscription(
|
||||||
db_client,
|
db_client,
|
||||||
&sender.id,
|
&sender.id,
|
||||||
|
|
Loading…
Reference in a new issue