mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-03 12:23:02 +01:00
Handle subscription case where it's set to trial, but renewal_date is not set. set the renewal_date for LENGTH_OF_FREE_TRIAL days from subscription creation.
This commit is contained in:
parent
889dbd738a
commit
2b2564257e
1 changed files with 5 additions and 0 deletions
|
@ -301,6 +301,11 @@ def subscription_to_state(subscription: Subscription) -> str:
|
||||||
return SubscriptionState.INVALID.value
|
return SubscriptionState.INVALID.value
|
||||||
elif subscription.type == Subscription.Type.TRIAL:
|
elif subscription.type == Subscription.Type.TRIAL:
|
||||||
# Check if the trial has expired
|
# Check if the trial has expired
|
||||||
|
if not subscription.renewal_date:
|
||||||
|
# If the renewal date is not set, set it to the current date + trial length and evaluate
|
||||||
|
subscription.renewal_date = subscription.created_at + timedelta(days=LENGTH_OF_FREE_TRIAL)
|
||||||
|
subscription.save()
|
||||||
|
|
||||||
if subscription.renewal_date and datetime.now(tz=timezone.utc) > subscription.renewal_date:
|
if subscription.renewal_date and datetime.now(tz=timezone.utc) > subscription.renewal_date:
|
||||||
return SubscriptionState.EXPIRED.value
|
return SubscriptionState.EXPIRED.value
|
||||||
return SubscriptionState.TRIAL.value
|
return SubscriptionState.TRIAL.value
|
||||||
|
|
Loading…
Reference in a new issue