Call subscription_to_state with sync_to_async wrapper when getting user subscription state

- This is needed in case the renewal_date is not set and we need to reset it for the user
This commit is contained in:
sabaimran 2024-11-02 12:22:35 -07:00
parent ec44cbe1e7
commit 075b4ecf15

View file

@ -333,7 +333,7 @@ async def aget_user_subscription_state(user: KhojUser) -> str:
Valid state transitions: trial -> subscribed <-> unsubscribed OR expired
"""
user_subscription = await Subscription.objects.filter(user=user).afirst()
return subscription_to_state(user_subscription)
return await sync_to_async(subscription_to_state)(user_subscription)
async def ais_user_subscribed(user: KhojUser) -> bool: