question packs instead of monthly/yearly plans; hearts are real

- packs (20 / 60 / 150 questions for 45,000 / 119,000 / 259,000 toman) never expire and
  give 7 / 30 / 60 days of unlimited hearts; old subscription plans stay for existing
  subscribers but are no longer on sale
- credit ledger (subscription.QuestionCredit): +N per paid pack (once per order), -1 per
  tutor question that reaches the API; the free daily questions are spent first; questions
  stopped by the server filter, cached answers and failed answers cost nothing
- unlimited hearts from packs live in HeartsPass, so buying a pack never rewrites a
  running subscription
- Message.charge records how each question was paid; GET /api/ai/quota and the ask
  responses report free-left-today and credits
- HEARTS_ENFORCED now defaults to on: zero hearts stops answering until refill or a pack

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-02 11:41:39 +03:30
parent 2edc56fc08
commit 58c8e6d014
18 changed files with 572 additions and 55 deletions

View File

@@ -720,10 +720,10 @@ OTP_SMS_TEMPLATE = os.environ.get(
NODE_PROGRESS_ABANDON_DAYS = 14
# قلبِ صفر جلوی جواب دادن را در سرور بگیرد؟ (content.views.QuestionAnswerView)
# خاموش تا وقتی فرانت برای ۴۰۳ِ `no_hearts` صفحه‌ی «قلب‌ها تمام شد» و زمانِ
# nextRefillAt را نشان دهد؛ روشن کردنش پیش از آن، دانش‌آموزِ بی‌قلب را به
# صفحه‌ی خطای عمومی می‌برد. تا آن موقع «قلبِ نامحدودِ» اشتراک فقط در اپ است.
HEARTS_ENFORCED = os.environ.get('HEARTS_ENFORCED', '0') == '1'
# از ۲۰۲۶-۱۰-۰۲ روشن است (خواستِ صاحبِ پروژه): فرانت ۴۰۳ِ `no_hearts` را با صفحه‌ی «قلب‌هایت
# تمام شد» و زمانِ پر شدن نشان می‌دهد، و قلبِ نامحدودِ هدیه‌ی بسته‌ها بدونِ این اثری نداشت.
# HEARTS_ENFORCED=0 در .env آن را خاموش می‌کند.
HEARTS_ENFORCED = os.environ.get('HEARTS_ENFORCED', '1') == '1'
# تلاشِ ورودِ ادمین در ۱۵ دقیقه برای هر IP.
ADMIN_LOGIN_MAX_ATTEMPTS = 10