From 57ccc3d70c03041114cfc48677d51072dee843bc Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 30 Oct 2026 13:52:03 +0200 Subject: [PATCH] fix(subscription): keep access until last second of the term - is_subscribed used _days_until() (floor), blocking generation for the whole last day when <24h remained though subscription was still active; now checks absolute expiry timestamp (expires > now) - covers all gated actions (post generation, ideas) via _check_subscription --- VERSION | 2 +- user_store.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 1f44f48..94a02a2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.0+83 +0.1.0+84 diff --git a/user_store.py b/user_store.py index 476db9a..1bae72e 100644 --- a/user_store.py +++ b/user_store.py @@ -281,13 +281,19 @@ def deactivate_subscription(user_id: int, db_path: str | None = None) -> None: def is_subscribed(user_id: int, db_path: str | None = None) -> bool: - """Правда ли подписка активна (срок не истёк).""" + """Правда ли подписка активна (срок не истёк). + + Проверяем по абсолютному UTC-моменту истечения, а не по целым оставшимся + дням: доступ действует до последней секунды срока, весь «последний день». + """ sub = subscription_row(user_id, db_path) - if not sub: + if not sub or not sub["is_active"]: return False - if not sub["is_active"]: + expires = _subscription_expires_at(sub) + if expires is None: return False - return _days_until(sub) > 0 + now = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) + return expires > now def add_post_samples(user_id: int, posts: list[str], db_path: str | None = None) -> list[str]: