Merge branch 'master' of github.com:khoj-ai/khoj into features/advanced-reasoning

This commit is contained in:
sabaimran 2024-10-30 11:32:10 -07:00
commit 82f3d79064

View file

@ -301,6 +301,11 @@ def subscription_to_state(subscription: Subscription) -> str:
return SubscriptionState.INVALID.value
elif subscription.type == Subscription.Type.TRIAL:
# 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:
return SubscriptionState.EXPIRED.value
return SubscriptionState.TRIAL.value