From 7f5bf35806550eed155dee7bcc25e1d726744ab8 Mon Sep 17 00:00:00 2001 From: sabaimran Date: Fri, 22 Nov 2024 12:06:20 -0800 Subject: [PATCH] Disambiguate renewal_date type. Previously, being used as None, False, and Datetime in different places. --- src/khoj/database/adapters/__init__.py | 2 +- src/khoj/routers/api_subscription.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/khoj/database/adapters/__init__.py b/src/khoj/database/adapters/__init__.py index fbfd5423..46a65c79 100644 --- a/src/khoj/database/adapters/__init__.py +++ b/src/khoj/database/adapters/__init__.py @@ -345,7 +345,7 @@ async def set_user_subscription( user_subscription.type = type if is_recurring is not None: user_subscription.is_recurring = is_recurring - if renewal_date is False: + if renewal_date is None: user_subscription.renewal_date = None elif renewal_date is not None: user_subscription.renewal_date = renewal_date diff --git a/src/khoj/routers/api_subscription.py b/src/khoj/routers/api_subscription.py index b583a991..71300f04 100644 --- a/src/khoj/routers/api_subscription.py +++ b/src/khoj/routers/api_subscription.py @@ -67,7 +67,7 @@ async def subscribe(request: Request): elif event_type in {"customer.subscription.updated"}: user_subscription = await sync_to_async(adapters.get_user_subscription)(customer_email) - renewal_date = False + renewal_date = None if subscription["current_period_end"]: 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"}: # Reset the user to trial state 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