Commit Graph
34 Commits
Author SHA1 Message Date
Mak5er 723df68feb admin: remove Message by Chat ID from main admin panel and return back to history on cancel 2026-09-15 00:20:22 +03:00
Mak5er 9f77fac8f8 feat(admin): add download history dialog with pagination, filters, and chat messaging 2026-09-14 23:12:40 +03:00
Mak5er ff08a681fd feat(broadcast): add token bucket rate limiter, forum topic support, and broadcast delivery report 2026-09-08 17:16:51 +03:00
Mak5er c960fc1ae1 feat: add automatic detection and migration when groups upgrade to supergroups 2026-09-08 17:00:48 +03:00
Mak5er 07b96ee040 feat(admin): implement segmented mailing, group reach verification, and admin UI 2026-09-08 16:27:00 +03:00
Mak5er b4d9d000b0 feat: separate users and groups, track group membership, and improve admin stats 2026-09-08 16:11:12 +03:00
Mak5erandClaude Fable 5 caffc343af refactor: apply full-project audit — bug fixes, performance, deduplication
Full-codebase audit (149 raw findings, 57 verified and applied).

Fixes:
- download resume: recompute Range header per retry attempt; never resume
  preallocated multipart .part files (silent media corruption)
- inline sends: canonical error tail (rate-limit/queue-busy/timeout/failure)
  for all platforms; YouTube inline no longer strands tokens in
  'processing' for 6h
- admin mailing: exclude banned users; fix Telegram error-text matching
- middlewares: instantiate once and share across message/callback/inline
  so antiflood/ban state no longer fragments
- event loop: move ZIP compression, JSON state persistence, admin FS
  walks, PIL/ffmpeg/ffprobe work off the loop
- download queue: prune idle per-user scopes; cancelled leader releases
  joined duplicate requests
- worker subprocess: disable log sinks (stderr error protocol and log
  rotation no longer race the parent)
- third-party loggers route through app handlers instead of lastResort
- tiktok: fix mojibake reaction emoji; per-user settings in doc callback;
  per-URL locks for short-URL expansion; parallel photo-set downloads
- ci: fix broken yt-dlp auto-bump workflow baseline
- db: drop redundant analytics_events indexes (migration 000010)

Refactoring:
- services/inline/send_flow.py: shared inline delivery flow for all five
  platforms (~640 duplicated lines removed)
- services/media/audio_flow.py: shared MP3 pipeline (was duplicated 6x
  across youtube/youtube_inline/soundcloud/spotify)
- CobaltMediaService base + shared Cobalt response parsing
- services/platforms/ytdlp_helpers.py: shared yt-dlp scaffolding
- register_inline_send_handlers: one chosen_inline_result/callback
  registration factory for 8 handlers
- merge pinterest/threads single-media and media-group flows
- logging decorator factory; remove ~11 dead repository methods

Tests: 470 -> 518 passing, coverage 77.3% -> 80.9% (CI gate 74%).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-26 16:25:59 +03:00
Mak5er 635e50b407 feat(settings): add media quality & file options, ZIP multi-photo archives, and categorized /settings UI
- Add video_quality, as_document, audio_format, and file_button to user settings schema and Alembic migrations.
- Categorize /settings into Media & Quality, Appearance & Buttons, and Chat & Clean-up with dynamic back navigation.
- Implement strict document delivery with disable_content_type_detection=True to prevent Telegram video player fallback when as_document is ON.
- Add multi-photo ZIP archive packaging for photo carousels in as_document mode.
- Differentiate DB media file cache entries between video and document types (url#document vs url#video) to eliminate cache collisions.
- Hide redundant Download File inline button when as_document setting is active.
- Remove obsolete referral system (/ref command and links).
2026-07-22 13:18:09 +03:00
Mak5er 20fc1ea6d3 perf: consolidate 5 admin count queries into single SQL 2026-06-18 18:35:54 +03:00
Mak5er 62050a0f2c perf: comprehensive production audit and hardening (Phase 1-4)
43 files changed, 828 insertions, 408 deletions. Key changes:

== Phase 1 - Critical fixes ==
- Fix shared mutable state in ResilientDownloader (class-level _inflight_downloads)
- Add threading.Lock to request dedup (race condition on concurrent claims)
- Fix ban_middleware fail-closed: DB error -> fallback to 'active' instead of 'restricted'
- Fix COUNT(*) anti-pattern: 5 methods fetched entire user table into memory
- Remove 6 duplicated function definitions in user_messages.py (silent shadowing)
- Extract metadata from Cobalt responses (Instagram no longer discards descriptions)
- Add SSRF validation for COBALT_API_URL (private IP blocking, scheme enforcement)
- Docker: healthcheck, resource limits, restart: on-failure:5
- Fix migration crash-loop (try/except guardrails + dialect detection bug)

== Phase 2 - Performance hardening ==
- Exponential backoff+jitter in cobalt_client and retry_async_operation (removed 9 fixed delays)
- Add asyncio.wait_for timeouts to Instagram/Pinterest downloads
- TikTok preflight size check before download
- SQLAlchemy pool event listeners (perf metrics on checkout/overflow)
- DownloadedFile TTL cleanup (date_added index + daily cron cleanup)
- Per-request UUID request_id in ChatTrackerMiddleware for end-to-end tracing
- private_chat_guard caching (60s TTL, reduces Telegram API calls)
- Antiflood O(k) eviction instead of O(n) full scan
- TikTok: Semaphore(3)+sliding-window rate limiter instead of global asyncio.Lock

== Phase 3 - CI hardening ==
- CI: lint job (ruff + mypy), docker smoke tests migrations, --cov-fail-under=80
- Upgrade dependency-audit Python 3.12 -> 3.14
- Fix 7 '# type: ignore' decorators with ParamSpec
- Migration 000005: ix_analytics_events_user_id + ix_downloaded_files_date_added
- Race-condition tests for dedup, queue shutdown, per-user slots

== Phase 4 - Architecture ==
- .dockerignore (exclude .git, tests, __pycache__, .env from Docker image)
- Consolidate 3 FakeYoutubeDL/DummyYDL classes into conftest.py
- Extract _download_youtube_media() from 70-line closure
- BasePlatformMediaService ABC in services/platforms/__init__.py
- Remove empty profiling/ directory

Tests: 349 passed, 0 failed (4 skipped: PostgreSQL-dependent)
2026-06-16 01:01:06 +03:00
Mak5er 91b84c83b2 feat(admin): streamline runtime control panel 2026-04-10 21:03:23 +03:00
Mak5er 77c4cda0b8 Refactor logging paths and stabilize db tests 2026-04-10 00:42:21 +03:00
Mak5er d18e0d4b5c chore: clean package exports and lint issues 2026-04-09 16:24:06 +03:00
Mak5er e43826a5fa perf: warm stats charts and surface analytics drops 2026-04-09 00:00:45 +03:00
Mak5er a9389dbf6e fix: clean nested download artifacts safely 2026-04-08 23:48:04 +03:00
Mak5er bb964728a7 refactor: organize services into domain subpackages 2026-04-07 01:08:39 +03:00
Mak5er 29795b9710 refactor: move runtime dependencies into app context 2026-04-07 00:24:38 +03:00
Mak5er 0fe5f8d0d3 perf: add bounded concurrency to admin bulk operations
- run active-user checks and mass mailing through a shared bounded-concurrency helper
- keep per-user pacing while avoiding fully sequential admin jobs
- remove the completed admin throughput finding from the review backlog
2026-04-06 23:40:59 +03:00
Mak5er bf9590ac36 fix: make nightly download cleanup queue-aware
- expose a lightweight queue load snapshot for admin maintenance tasks
- skip scheduled cleanup while downloads are active or queued
- only purge older files during cleanup and update the review backlog accordingly
2026-04-06 23:36:02 +03:00
Mak5er 784aee9747 fix: harden inline delivery and bot runtime safeguards
- secure admin callbacks and inline token ownership checks
- stabilize private chat handoff and fail-soft user settings reads
- improve inline album previews with captions, photo file_ids, and API-safe payloads
- fix download manager dedup, resume validation, and size-limit propagation
- add regression coverage for admin, db, runtime, inline, and download flows
2026-04-06 23:07:26 +03:00
Mak5er 3964d96158 Refactor database interactions and improve URL handling
- Updated user management in `admin.py` to use `get_all_users_info` and streamline user status updates.
- Refactored TikTok URL processing in `tiktok.py` to use asynchronous HTTP requests and caching.
- Enhanced Twitter handler in `twitter.py` to support async operations and improved error handling.
- Simplified user information updates in `user.py` with a new `upsert_chat` method.
- Optimized utility functions in `utils.py` for better performance and added caching for message edits.
- Updated middleware in `chat_tracker.py` to utilize the new `upsert_chat` method for user tracking.
- Improved test coverage for TikTok and Twitter handlers, ensuring async compatibility and error handling.
2026-03-14 13:43:56 +02:00
Mak5er 8adca9f43d Refactor inline delivery, cleanup dependencies, and overhaul logging
What changed:

- unified inline media delivery across TikTok, Instagram, Pinterest, SoundCloud, YouTube, and Twitter around a single editable-message flow with chosen-inline auto start and callback fallback

- added reusable inline request state/services, service icons, album deep links, and single-message inline progress/edit helpers

- enabled inline support for regular YouTube videos, Twitter inline media, and Twitter multi-photo album deep links; aligned Pinterest/Instagram/TikTok inline behaviors

- cleaned dead duplicated inline code, extracted shared inline request guards, and expanded tests around TikTok, Pinterest, SoundCloud, and YouTube handlers

- optimized project setup with trimmed runtime requirements, requirements-dev split, .dockerignore, Docker/compose improvements, and README updates

- rebuilt logging with structured context-aware adapters, request scoped flow decorators, JSONL event/perf logs, queue/download/cobalt timing events, and safer extra field sanitization to avoid LogRecord key collisions
2026-03-13 00:18:29 +02:00
mak5er 943d14ccea chore: refresh bot copy and keyboard flow 2026-02-16 00:39:27 +02:00
mak5er 83b425393c feat: add adaptive download queue, retries, and session observability 2026-02-11 17:01:46 +02:00
Mak5er 55bd0bf03e Add ChatTrackerMiddleware for user and chat tracking, update analytics event handling, and improve admin functionalities 2025-11-03 11:08:55 +02:00
Mak5er d5664a0362 Add functionality to send messages by chat ID and update admin panel statistics 2025-11-03 10:30:30 +02:00
Mak5er 0879c3a51b Add active users check functionality and update admin interface 2025-11-03 10:00:49 +02:00
Mak5er 3d3aad3a94 Refactor error handling to use logging instead of print statements and update Python SDK version in project files 2025-04-10 23:02:27 +03:00
Mak5er 27b829390e Refactor database handling to use SQLAlchemy and improve user management functionality 2025-03-08 13:50:42 +02:00
Mak5er 2f351df725 Refactor error handlers to improve error logging and enhance exception handling 2025-03-08 01:08:06 +02:00
Mak5er 5b3124731c Refactor Instagram and TikTok handlers for improved error handling and logging; update API URLs and message responses 2025-02-22 12:39:20 +02:00
Mak5er 45b574aaf0 updated some features 2025-02-10 17:19:54 +02:00
Mak5er 2b87bc74d5 Fixed YouTube downloads and added cleaning for downloads folder 2024-11-24 14:54:31 +02:00
Mak5er c4818c7790 add admin, optimized code and add music time 2024-06-23 23:22:39 +03:00