mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-03 05:29:12 +00:00
Use sql datetime comparison for detecting validity of subscription renewal date
- Update the unsubscribe endpoint to use query params - Use subscription id to process unsubscribe endpoint, rather than the customer id
This commit is contained in:
@@ -2,7 +2,7 @@ from typing import Type, TypeVar, List
|
||||
from datetime import date, datetime, timedelta
|
||||
import secrets
|
||||
from typing import Type, TypeVar, List
|
||||
from datetime import date
|
||||
from datetime import date, timezone
|
||||
|
||||
from django.db import models
|
||||
from django.contrib.sessions.backends.db import SessionStore
|
||||
@@ -116,12 +116,9 @@ async def set_user_subscribed(email: str, type="standard") -> KhojUser:
|
||||
|
||||
|
||||
def is_user_subscribed(email: str, type="standard") -> bool:
|
||||
user = KhojUser.objects.filter(email=email, subscription_type=type).first()
|
||||
if user and user.subscription_renewal_date:
|
||||
is_subscribed = user.subscription_renewal_date > date.today()
|
||||
return is_subscribed
|
||||
else:
|
||||
return False
|
||||
return KhojUser.objects.filter(
|
||||
email=email, subscription_type=type, subscription_renewal_date__gte=datetime.now(tz=timezone.utc)
|
||||
).exists()
|
||||
|
||||
|
||||
async def get_user_by_token(token: dict) -> KhojUser:
|
||||
|
||||
Reference in New Issue
Block a user