mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 15:38:55 +01:00
Disambiguate renewal_date type. Previously, being used as None, False, and Datetime in different places.
Some checks are pending
dockerize / Publish Khoj Docker Images (push) Waiting to run
build and deploy github pages for documentation / deploy (push) Waiting to run
pre-commit / Setup Application and Lint (push) Waiting to run
pypi / Publish Python Package to PyPI (push) Waiting to run
test / Run Tests (push) Waiting to run
Some checks are pending
dockerize / Publish Khoj Docker Images (push) Waiting to run
build and deploy github pages for documentation / deploy (push) Waiting to run
pre-commit / Setup Application and Lint (push) Waiting to run
pypi / Publish Python Package to PyPI (push) Waiting to run
test / Run Tests (push) Waiting to run
This commit is contained in:
parent
5e8c824ecc
commit
7f5bf35806
2 changed files with 3 additions and 3 deletions
|
@ -345,7 +345,7 @@ async def set_user_subscription(
|
||||||
user_subscription.type = type
|
user_subscription.type = type
|
||||||
if is_recurring is not None:
|
if is_recurring is not None:
|
||||||
user_subscription.is_recurring = is_recurring
|
user_subscription.is_recurring = is_recurring
|
||||||
if renewal_date is False:
|
if renewal_date is None:
|
||||||
user_subscription.renewal_date = None
|
user_subscription.renewal_date = None
|
||||||
elif renewal_date is not None:
|
elif renewal_date is not None:
|
||||||
user_subscription.renewal_date = renewal_date
|
user_subscription.renewal_date = renewal_date
|
||||||
|
|
|
@ -67,7 +67,7 @@ async def subscribe(request: Request):
|
||||||
elif event_type in {"customer.subscription.updated"}:
|
elif event_type in {"customer.subscription.updated"}:
|
||||||
user_subscription = await sync_to_async(adapters.get_user_subscription)(customer_email)
|
user_subscription = await sync_to_async(adapters.get_user_subscription)(customer_email)
|
||||||
|
|
||||||
renewal_date = False
|
renewal_date = None
|
||||||
if subscription["current_period_end"]:
|
if subscription["current_period_end"]:
|
||||||
renewal_date = datetime.fromtimestamp(subscription["current_period_end"], tz=timezone.utc)
|
renewal_date = datetime.fromtimestamp(subscription["current_period_end"], tz=timezone.utc)
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ async def subscribe(request: Request):
|
||||||
elif event_type in {"customer.subscription.deleted"}:
|
elif event_type in {"customer.subscription.deleted"}:
|
||||||
# Reset the user to trial state
|
# Reset the user to trial state
|
||||||
user, is_new = await adapters.set_user_subscription(
|
user, is_new = await adapters.set_user_subscription(
|
||||||
customer_email, is_recurring=False, renewal_date=False, type=Subscription.Type.TRIAL
|
customer_email, is_recurring=False, renewal_date=None, type=Subscription.Type.TRIAL
|
||||||
)
|
)
|
||||||
success = user is not None
|
success = user is not None
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue