diff --git a/src/khoj/database/adapters/__init__.py b/src/khoj/database/adapters/__init__.py index 46a65c79d..151abc839 100644 --- a/src/khoj/database/adapters/__init__.py +++ b/src/khoj/database/adapters/__init__.py @@ -224,7 +224,9 @@ async def acreate_user_by_phone_number(phone_number: str) -> KhojUser: ) await user.asave() - await Subscription.objects.acreate(user=user, type=Subscription.Type.STANDARD) + user_subscription = await Subscription.objects.filter(user=user).afirst() + if not user_subscription: + await Subscription.objects.acreate(user=user, type=Subscription.Type.STANDARD) return user @@ -296,7 +298,9 @@ async def create_user_by_google_token(token: dict) -> KhojUser: user=user, ) - await Subscription.objects.acreate(user=user, type=Subscription.Type.STANDARD) + user_subscription = await Subscription.objects.filter(user=user).afirst() + if not user_subscription: + await Subscription.objects.acreate(user=user, type=Subscription.Type.STANDARD) return user