feat: add multi-channel mandatory subscription system

- Multi-channel subscription enforcement via middleware, events, and cabinet API
- 3-layer cache architecture: Redis -> PostgreSQL -> rate-limited Telegram API
- ChatMemberUpdated event-driven tracking with automatic VPN access control
- Admin management via bot FSM handler and REST API with full CRUD
- Channel ID normalization: @username resolved to numeric ID at creation time
- Fail-closed error handling: API errors deny access (security-first)
- Background reconciliation with keyset pagination (100 per batch)
- Per-user rate limiting on subscription check button (5s cooldown)
- Redis connection pooling via cache singleton (no per-request connections)
- Database: channel_id index, multi-row upsert optimization
- Localization: en, ru, zh, fa, ua translations for all new strings
- Frontend blocking UI with channel list and subscription status
- Admin channel management page with toggle, delete, and create
This commit is contained in:
Fringg
2026-02-24 02:50:18 +03:00
parent 751e312f28
commit 8375d7ecc5
36 changed files with 1906 additions and 636 deletions
+4
View File
@@ -287,6 +287,10 @@ async def main():
daily_subscription_service.set_bot(bot)
telegram_notifier.set_bot(bot)
from app.services.channel_subscription_service import channel_subscription_service
channel_subscription_service.bot = bot
# Initialize email broadcast service
from app.cabinet.services.email_service import email_service
from app.services.broadcast_service import email_broadcast_service