Commit 00214e85 authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Add bulk Telegram chat scanning: approve a chat, tag+save every song in it

New foundation for scanning a whole chat instead of one song at a time:
ApprovedChat (opt a chat in) and ChatScanJob (a background job that
lists a chat's music, then downloads+identifies+tags+saves each song
via the same pipeline /music/tag already uses per song). Mirrors
RemixJob's proven pattern - a status column + BackgroundTasks, no new
task-queue infrastructure - rather than inventing a new one.

Deliberately on-demand (user approves a chat, then triggers one scan)
rather than automatic background polling, which needs a materially
different architecture (persistent per-user Telegram connections or a
scheduler) not worth building until on-demand proves out the feature.

Guardrails baked in from the start rather than bolted on later: a
50-message cap per scan, a 5-scans/day per-user cap, no two concurrent
scans of the same chat, and a 1.5s pause between songs so a scan reads
like a real user, not a script hammering Telegram/AcoustID/Gemini.
Per-song outcomes (saved/skipped_duplicate/failed) are tracked
individually in results_json, not just one pass/fail for the whole job.

_identify_tag_and_store's request param is now optional so the
background job can call it without a live HTTP request in scope - same
reasoning as RemixJob storing a bare filename instead of a full URL.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent 98dbaf27
Pipeline #1112 passed with stage
in 3 minutes and 13 seconds