Commit Graph

267 Commits

Author SHA1 Message Date
Fringg
fe5f5ded96 feat: add MULENPAY_WEBSITE_URL setting for post-payment redirect
Previously website_url was hardcoded to WEBHOOK_URL, redirecting users
to the webhook endpoint after payment. Now configurable via env var.
2026-02-10 07:25:58 +03:00
Fringg
6d67cad3e7 feat: add RemnaWave incoming webhooks for real-time subscription events
- Add FastAPI webhook endpoint with HMAC-SHA256 signature verification
- Handle 16 user events: expired, disabled, enabled, limited, traffic_reset,
  modified, deleted, revoked, created, expires_in_72h/48h/24h,
  expired_24h_ago, first_connected, bandwidth_threshold
- URL validation for subscription_url/subscription_crypto_link (XSS prevention)
- 64KB body size limit, 32-char minimum secret enforcement
- Sanitized percent value in bandwidth threshold notifications
- DB rollback on handler errors to prevent dirty session commits
- Localization for all 5 languages (ru, en, ua, zh, fa)
2026-02-10 05:13:39 +03:00
Fringg
119f463c36 refactor: remove Flask, use FastAPI exclusively for all webhooks
Delete dead Flask-based PAL24 webhook server (app/external/pal24_webhook.py).
PAL24 webhooks already handled by unified FastAPI server on port 8080.

- Remove flask dependency from pyproject.toml and requirements.txt
- Remove PAL24_WEBHOOK_PORT config (unused, FastAPI uses shared port)
- Remove pal24_webhook module reference from log filter
- Update docs: webhook example rewritten from Flask to FastAPI
- Uninstall flask, werkzeug, blinker, itsdangerous
2026-02-09 21:54:15 +03:00
Fringg
a3903a252e refactor: remove smart auto-activation & activation prompt, fix production bugs
Remove AUTO_ACTIVATE_AFTER_TOPUP and SHOW_ACTIVATION_PROMPT_AFTER_TOPUP
features from all payment providers, config, system settings, and tests.
Cart auto-purchase (AUTO_PURCHASE_AFTER_TOPUP) is preserved.

Bug fixes:
- fix KeyError 'months' in devices.py for custom locale overrides
- fix IntegrityError on trial subscription retry (update existing PENDING instead of INSERT)
- fix PendingRollbackError cascade by adding db.rollback() before recovery
- fix TelegramForbiddenError not caught in photo_message.py
- fix "query is too old" spam in required_sub_channel_check
- add missing trial locale keys (TRIAL_PAYMENT_DESCRIPTION, TRIAL_REFUND_DESCRIPTION, TRIAL_ACTIVATION_ERROR)
2026-02-09 21:39:53 +03:00
Egor
cc54a7ad2f Merge pull request #2580 from xenral/main
feat(localization): add Persian (fa) locale support and wire it across app flows
2026-02-09 21:09:43 +03:00
Fringg
efa3a5d457 refactor: remove "both" mode from BOT_RUN_MODE, keep only polling and webhook 2026-02-09 17:32:17 +03:00
Ali Morshedzadeh
5482e609f8 Add initial Persian locale support and language handling updates 2026-02-09 16:53:50 +03:30
Fringg
d6fa86b870 fix: remove dots from Remnawave username sanitization
Remnawave API only allows letters, numbers, underscores and dashes in
usernames. The sanitizer regex was also allowing dots, causing OAuth
users with email-based usernames (e.g. john.doe@gmail.com) to fail
subscription creation with "Validation failed: invalid_string".
2026-02-08 19:00:03 +03:00
Fringg
0de6418bca refactor: add strict typing to OAuth providers, replace urlencode with httpx params 2026-02-07 02:14:37 +03:00
Fringg
97be4afbff feat: add OAuth 2.0 authorization (Google, Yandex, Discord, VK)
- Add OAuth provider config vars and helpers to config.py
- Add google_id, yandex_id, discord_id, vk_id columns to User model
- Create OAuth provider service with state management and 4 providers
- Add CRUD functions for OAuth user lookup, linking, and creation
- Add 3 API endpoints: providers list, authorize URL, callback
- Add alembic migration and universal_migration support
- Fix trial disable logic to cover OAuth auth_types
2026-02-07 01:58:55 +03:00
Fringg
116c8453bb feat: block registration with disposable email addresses
Add DisposableEmailService that fetches ~72k disposable email domains
from github.com/disposable/disposable-email-domains into an in-memory
frozenset with 24h auto-refresh via asyncio background task.

Integrated into three email entry points in cabinet auth routes:
- POST /email/register (link email to Telegram account)
- POST /email/register/standalone (standalone email registration)
- POST /email/change (change existing email)

Controlled by DISPOSABLE_EMAIL_CHECK_ENABLED setting (default: true).
Falls back to allowing all emails if domain list fetch fails.
2026-02-07 00:34:11 +03:00
Fringg
c4794db1dd feat: add TRIAL_DISABLED_FOR setting to disable trial by user type
New setting allows granular control over trial availability:
- none: trial available for all (default)
- email: trial disabled for email users
- telegram: trial disabled for telegram users
- all: trial disabled for everyone

Enforced in bot handlers, cabinet API, and miniapp routes.
Automatically appears in admin panel as dropdown via CHOICES.
2026-02-07 00:19:25 +03:00
Egor
0c769ac16d Update config.py 2026-01-30 16:06:28 +03:00
c0mrade
02f8826132 fix(config): make SMTP credentials optional for servers without AUTH 2026-01-25 14:43:59 +03:00
Egor
d6f4ea1d43 Update config.py 2026-01-25 09:56:00 +03:00
Egor
7b42bfd02d Update config.py 2026-01-25 09:43:15 +03:00
c0mrade
9a2aea038a chore: add uv package manager and ruff linter configuration
- Add pyproject.toml with uv and ruff configuration
- Pin Python version to 3.13 via .python-version
- Add Makefile commands: lint, format, fix
- Apply ruff formatting to entire codebase
- Remove unused imports (base64 in yookassa/simple_subscription)
- Update .gitignore for new config files
2026-01-24 17:45:27 +03:00
Egor
fe73128a9e Update config.py 2026-01-23 11:29:50 +03:00
Mikhail
060ae9decf Merge branch 'BEDOLAGA-DEV:main' into main 2026-01-21 09:49:12 +03:00
Egor
d0628eebda Update config.py 2026-01-21 07:33:54 +03:00
gy9vin
7aa64521d2 feat(payments): добавить KassaAI как отдельную платёжную систему
Новая платёжка KassaAI (api.fk.life) работает параллельно с Freekassa.

  Добавлено:
  - app/services/kassa_ai_service.py — API-сервис
  - app/database/crud/kassa_ai.py — CRUD-операции
  - app/services/payment/kassa_ai.py — KassaAiPaymentMixin
  - app/handlers/balance/kassa_ai.py — хендлеры пополнения

  Изменено:
  - config.py — настройки KASSA_AI_*
  - models.py — PaymentMethod.KASSA_AI, модель KassaAiPayment
  - payment_service.py — подключён KassaAiPaymentMixin
  - webserver/payments.py — webhook /kassa-ai-webhook
  - keyboards/inline.py — кнопка KassaAI
  - handlers/balance/main.py — регистрация хендлеров
  - universal_migration.py — миграция таблицы kassa_ai_payments
  - system_settings_service.py — настройки в админке
  - .env.example — примеры переменных

  Способы оплаты: 44=СБП, 36=Карты РФ, 43=SberPay
2026-01-20 19:09:27 +03:00
Egor
17b442ad07 Update config.py 2026-01-17 02:49:14 +03:00
Egor
02ae44a594 Merge pull request #2298 from Gy9vin/main
Мониторинг трафика v2
2026-01-16 17:56:10 +03:00
PEDZEO
b392a99f56 Интеграция системы мониторинга банов 2026-01-16 15:17:02 +03:00
gy9vin
1c2dca2c65 fix(traffic): исправлены критические баги мониторинга трафика v2
- Исправлен баг с пустым snapshot {} (не распознавался как существующий)
- Исправлено игнорирование комментариев в TRAFFIC_MONITORED_NODES
- Добавлено исключение пользователей по UUID (TRAFFIC_EXCLUDED_USER_UUIDS)
- Добавлены названия нод в уведомления о превышении трафика
- Улучшено логирование: кулдаун, фильтры, исключённые пользователи
- Исправлен баг с блокировкой имён типа "Сейтмеметов" (ложное срабатывание на "тме")
- Разрешён конфликт слияния в display_name_restriction.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 12:19:29 +03:00
gy9vin
ab492f3aef Мониторинг и исправления защиты имени пользователя! 2026-01-16 12:18:04 +03:00
Mikhail
1c7ed68674 Merge branch 'main' into main 2026-01-16 12:16:23 +03:00
Egor
be9d7290cb Update config.py 2026-01-16 04:56:34 +03:00
Egor
79904b58a9 Update config.py 2026-01-15 18:42:23 +03:00
PEDZEO
a53219525f Merge pull request #2284 from BEDOLAGA-DEV/buttons
Enhance ban notification system with delete functionality and improve…
2026-01-14 14:56:43 +03:00
PEDZEO
c868ef3b69 Enhance ban notification system with delete functionality and improved message formatting
- Added a new handler to delete ban notifications upon user interaction.
- Introduced a delete button in ban notifications for better user experience.
- Updated ban notification messages to include node information more prominently.
- Refactored the BanNotificationService to send messages with the delete button included.
2026-01-14 14:50:00 +03:00
PEDZEO
34b87cba88 Merge pull request #2283 from BEDOLAGA-DEV/buttons
Enhance ban notification messages and service to include node informa…
2026-01-14 14:10:24 +03:00
PEDZEO
3aa5e304c3 Enhance ban notification messages and service to include node information
- Updated ban notification messages to provide detailed reasons for account bans, including node information.
- Refactored the BanNotificationService to safely format messages with optional node details.
- Modified API routes and schemas to support the inclusion of node names in ban notifications.
2026-01-14 14:03:09 +03:00
PEDZEO
b49031ea72 Merge pull request #2282 from BEDOLAGA-DEV/buttons
Add ban notification messages and refactor notification service
2026-01-14 07:33:02 +03:00
PEDZEO
243eef066c Add ban notification messages and refactor notification service
- Introduced new ban notification messages for device limit, WiFi, and mobile network violations in the configuration.
- Refactored the BanNotificationService to utilize the new messages from the configuration for sending notifications.
- Added a new method to handle mobile network ban notifications.
- Updated API routes to support the new notification type for mobile network bans.
2026-01-14 07:25:09 +03:00
Egor
6bea51b6dc Update config.py 2026-01-14 04:14:29 +03:00
Egor
4730cf30e9 Update config.py 2026-01-13 16:30:27 +03:00
Egor
ce7d7a206c Update config.py 2026-01-13 16:24:48 +03:00
Egor
fe4e261115 Merge pull request #2275 from BEDOLAGA-DEV/buttons
Buttons
2026-01-13 03:33:39 +03:00
Egor
e92b14391b Update config.py 2026-01-13 00:07:09 +03:00
PEDZEO
ac5850746e Merge pull request #2271 from BEDOLAGA-DEV/main
merge main
2026-01-12 22:25:49 +03:00
Egor
538c002f8f Add files via upload 2026-01-12 15:25:47 +03:00
PEDZEO
15f6108674 feat(tariffs): добавлена поддержка докупки трафика и улучшения тарифов
- Реализована возможность докупки трафика для тарифов с новыми параметрами: traffic_topup_enabled, traffic_topup_packages и max_topup_traffic_gb.
- Обновлены схемы и маршруты для управления тарифами и трафиком.
- Добавлены новые эндпоинты для работы с докупкой трафика в мини-приложении.
- Обновлены настройки и логика для проверки доступности докупки трафика в зависимости от тарифа.
- Внедрены улучшения в обработку платежей через Freekassa.

Обновлён .env.example с новыми параметрами для режима тарифов.
2026-01-12 07:47:35 +03:00
PEDZEO
0e24a5505c feat(subscription): добавлены новые функции для управления тарифами и трафиком
- Обновлены схемы и маршруты для поддержки покупки тарифов и управления трафиком.
- Реализована синхронизация тарифов и серверов из RemnaWave при запуске.
- Добавлены новые параметры в тарифы: server_traffic_limits и allow_traffic_topup.
- Обновлены настройки и логика для проверки доступности докупки трафика в зависимости от тарифа.
- Внедрены новые эндпоинты для работы с колесом удачи и обработка платежей через Stars.

Обновлён .env.example с новыми параметрами для режима продаж подписок.
2026-01-12 07:41:10 +03:00
Egor
011f4428e2 Update config.py 2026-01-10 19:41:18 +03:00
gy9vin
6e1d671df2 feat(traffic): добавлен новый мониторинг трафика v2 с проверкой дельты и snapshot
Новый функционал:
- Быстрая проверка (TRAFFIC_FAST_CHECK_*) — отслеживает дельту трафика за интервал через snapshot
- Суточная проверка (TRAFFIC_DAILY_CHECK_*) — анализирует трафик за 24 часа через bandwidth API
- Фильтрация по нодам (TRAFFIC_MONIT
2026-01-10 00:47:23 +03:00
gy9vin
eaeb6def51 feat(config): добавлено предупреждение после пополнения и обновлён .env.example
Новый функционал:
- SHOW_ACTIVATION_PROMPT_AFTER_TOPUP — показывает предупреждение с кнопками
  "Активировать", "Продлить", "Добавить устройства" после пополнения баланса,
  если подписка не активна (режим для новичков)

Обновлён .env.example (+138 строк):
- Redis: CART_TTL_SECONDS
- Remnawave: AUTO_SYNC_*, TRIAL_USER_TAG, PAID_SUBSCRIPTION_USER_TAG
- Трафик: BUY_TRAFFIC_BUTTON_VISIBLE, PRICE_TRAFFIC_UNLIMITED
- Автопродление: ENABLE_AUTOPAY
- Конкурсы: REFERRAL_CONTESTS_ENABLED
- YooKassa: TRUSTED_PROXY_NETWORKS
- Mulenpay: DISPLAY_NAME, IFRAME_EXPECTED_ORIGIN, DISPLAY_NAME_BANNED_KEYWORDS
- Platega: DISPLAY_NAME
- WATA: PUBLIC_KEY_CACHE_SECONDS, PUBLIC_KEY_URL
- CloudPayments: API_URL, WIDGET_URL, RETURN_URL
- Интерфейс: MENU_LAYOUT_ENABLED, MINIAPP_PURCHASE_URL, HAPP_DOWNLOAD_LINK_PC
- Web API: WORKERS, TITLE, VERSION, TOKEN_HASH_ALGORITHM, REQUEST_LOGGING,
  EXTERNAL_ADMIN_TOKEN, EXTERNAL_ADMIN_TOKEN_BOT_ID

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 11:16:52 +03:00
Mikhail
f25ed360fc Merge branch 'BEDOLAGA-DEV:main' into main 2026-01-08 08:12:45 +03:00
Egor
c31de445b9 Update config.py 2026-01-08 03:18:03 +03:00
gy9vin
3299d47b11 merge: resolve conflict in universal_migration.py 2026-01-07 15:05:14 +03:00