1. 06 Sep, 2026 1 commit
    • Aryan Noshirvnai's avatar
      Add shared-library search: /library/shared/search + /library/shared/claim · cab57b31
      Aryan Noshirvnai authored
      Every library query was scoped to the caller's own songs - there was no
      way to search what other users have already tagged. New search endpoint
      matches title/artist/genre across every user's library (same matching as
      the existing owner-scoped search), deduped by (title, artist) so a song
      several users separately uploaded doesn't show up once per owner, and
      excludes anything the caller already has by that same identity - the
      point is surfacing music that's new to them, not re-offering their own
      library back at them.
      
      Claiming a result reuses give_from_shared_library - the exact mechanism
      already backing Discovery's "identified something someone else has, give
      me a copy" flow - moved out of discovery.py into a new shared services
      module so both routers call the same code instead of one importing the
      other's private function. Picked up a drive-by fix in the move: it wasn't
      copying track_number, so a claimed song silently lost its real album
      order.
      
      Also fixed two unrelated pre-existing test collisions surfaced while
      adding these tests: the session-scoped test DB (no per-test rollback)
      meant test_music.py, test_discovery.py, and this file's own new tests all
      used identical "Shared Song"/"Shared Artist"-style literals, and a global
      (no user_id) title/artist lookup could resolve to the wrong test's
      leftover row depending on run order.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      cab57b31
  2. 03 Sep, 2026 3 commits
  3. 01 Sep, 2026 3 commits
  4. 31 Aug, 2026 2 commits
    • Aryan Noshirvnai's avatar
      Fix synced lyrics being silently skipped during tagging · 34fe74d2
      Aryan Noshirvnai authored
      The synced-lyrics lookup was only attempted when the identification
      candidate had no plain lyrics of its own - but Shazam and Gemini can
      both independently return a plain snippet as part of identification,
      which was short-circuiting the sync fetch entirely and silently
      discarding real timing data that was actually available. Now always
      attempted, with synced data (when found) always winning over whatever
      plain-text source identification provided.
      
      Also fixes the Discovery "give from shared library" path, which
      copied a source song's plain lyrics but not its synced_lyrics -
      copies given via Discovery were silently losing sync data even when
      the source had it.
      
      Existing tests never caught this because they always constructed a
      candidate with lyrics already stripped out; also fixes a shared
      mutable test fixture (FAKE_CANDIDATE) that the code under test
      mutates in place, which was silently leaking state between tests.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      34fe74d2
    • Aryan Noshirvnai's avatar
      Real line-synced lyrics: stop discarding LRC timing, store it · ae06a8fd
      Aryan Noshirvnai authored
      fetch_lyrics() now tries syncedlyrics with synced_only=True first (a real
      line-by-line-timed hit, not a fuzzy fallback) and only drops to plain-text
      search if nothing timed exists anywhere. Previously it always stripped
      timestamps immediately, throwing away data the frontend now needs for a
      real Spotify-style highlighted lyrics view.
      
      New synced_lyrics column (LibrarySong + IdentifiedTrack cache), JSON-encoded
      [[seconds, text], ...], threaded through the shared _identify_tag_and_store
      pipeline (upload, tag, and the Telegram bulk-scan job all go through it) and
      exposed via GET /library/lyrics/{file_id}.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      ae06a8fd
  5. 28 Aug, 2026 2 commits
    • Aryan Noshirvnai's avatar
      Switch all Gemini calls from 2.5-flash to 3.7-flash · 4d1f15ee
      Aryan Noshirvnai authored
      Genre fallback (music.py), Discovery's AI identification (music_identification.py),
      remix planning (remix_engine.py), and the Telegram bot's remix recipe parser
      (ai_remix.py) all move to the current flash model. Verified gemini-3.7-flash is a
      real, listed model for this API key via a live generateContent call before
      switching (returned a transient 503 "high demand" on first probe, not a 429/403
      access-denial - confirmed the key itself is fine with a control call against the
      old model in the same window).
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      4d1f15ee
    • Aryan Noshirvnai's avatar
      Discovery: give a match from any user's library, real confidence field; rate limit /remix · b1f5d610
      Aryan Noshirvnai authored
      Discovery hits now check the whole app's library (not just the caller's own) - if
      someone else (including a super-admin seed upload) already has the song, the finder
      gets their own LibrarySong row immediately, reusing the existing file_path rather
      than duplicating audio on disk. The library is built entirely from real uploads,
      never anything auto-downloaded, so this stays clear of the copyright concern raised
      earlier.
      
      AcoustID's match score and a fixed value for Shazam are now a real queryable
      confidence field on DiscoveredSong instead of embedded in a source string.
      
      POST /remix had no rate limiting despite being the one genuinely expensive endpoint
      (real Gemini spend + CPU-bound Demucs per call) - added the same DB-backed limiter
      pattern used elsewhere, reusing RemixJob.created_at as its own counter.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      b1f5d610
  6. 23 Aug, 2026 1 commit
  7. 22 Aug, 2026 4 commits
  8. 19 Aug, 2026 1 commit
    • Aryan Noshirvnai's avatar
      Add bulk Telegram chat scanning: approve a chat, tag+save every song in it · 00214e85
      Aryan Noshirvnai authored
      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
      00214e85
  9. 18 Aug, 2026 4 commits
  10. 16 Aug, 2026 2 commits
    • Aryan Noshirvnai's avatar
      Rate-limit /auth/login against brute force · 28e9ac64
      Aryan Noshirvnai authored
      Username/password login had zero rate limiting since it shipped - unlimited
      guesses against any account from anywhere. Adds a username column to the
      existing AuthAttempt table (migration d22ca64d291e) and reuses the same
      DB-backed approach already protecting /auth/telegram/request_code: 10
      attempts per account per 15 minutes, 100 per source per hour. Kept
      independent of the Telegram rate limit despite sharing a table - both
      _check_rate_limit and the new _check_login_rate_limit filter on their own
      column (phone_number.isnot(None) / username.isnot(None)) so hammering one
      endpoint never burns the other's budget.
      
      Verified live: 10 wrong-password attempts succeed with 401, the 11th (even
      with the correct password) gets 429; a telegram request_code call
      immediately after is unaffected.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      28e9ac64
    • Aryan Noshirvnai's avatar
      Add GET /playlists/{id} - playlist detail with ordered tracks · 31e1b608
      Aryan Noshirvnai authored
      The existing playlist endpoints (list, create, add-track) had no way to
      actually view what's in a playlist - GET /playlists only returns the
      playlist rows themselves, not their tracks. Joins PlaylistTrack to
      LibrarySong, ordered by track order, scoped to the owner. Needed to build
      a real Playlist UI on the frontend (playlists have had a working backend
      with zero UI since they were added).
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      31e1b608
  11. 15 Aug, 2026 8 commits
    • Aryan Noshirvnai's avatar
      Stream audio directly instead of downloading the whole file first · ab7b741e
      Aryan Noshirvnai authored
      Every stream endpoint (library, soundmarks, posts, live-location, rooms)
      only accepted the access token via an Authorization header - fine for
      apiFetch, but <audio src="..."> can't send custom headers, so the frontend
      was fetching the entire file as a blob before playback could even start
      (no progressive playback, no seeking). Added
      get_current_user_for_stream, which accepts the token as a ?token= query
      param too (same reasoning as the Rooms websocket fix), and switched all
      five stream endpoints to it. FileResponse already supports Range requests
      natively, so a direct <audio src> now gets real 206 Partial Content
      responses - confirmed live (curl -H "Range: ..." against
      /library/stream/1?token=...).
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      ab7b741e
    • Aryan Noshirvnai's avatar
      Fix the two known security gaps: /remix auth+IDOR, Rooms websocket user_id forgery · 913721b5
      Aryan Noshirvnai authored
      POST /remix and GET /remix/{job_id} previously had no authentication at all -
      user_id was a raw client-supplied form field, and job status was fetchable by
      guessing sequential ids (IDOR). Both endpoints now require a logged-in user;
      RemixJob gets a new user_id column (migration 347da5d41656) so job status is
      scoped to its owner. Also closed an adjacent IDOR found while fixing this:
      library_song_ids sourcing now scopes to the caller's own library, not any
      song id.
      
      WS /social/rooms/{room_id}/ws took user_id as an unauthenticated query
      param - anyone could connect claiming to be any user. It now takes a JWT
      access token instead (browsers can't set WS headers, so it travels as a
      query param) and verifies it - signature, expiry, real user row - before
      accepting the connection.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      913721b5
    • Aryan Noshirvnai's avatar
      Switch primary login to username/password, repurpose Telegram auth as account linking · c5585aed
      Aryan Noshirvnai authored
      Adds POST /auth/register and POST /auth/login (username/password, PBKDF2-hashed
      stdlib-only, no new dependency). The former phone/code Telegram flow moves to
      /auth/telegram/{request_code,login,chats,chats/{id}/music} - it now links a
      Telegram account (for the chat-scanning music-tagging feature) to an
      already-authenticated user rather than being the identity mechanism itself.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      c5585aed
    • Aryan Noshirvnai's avatar
      Replace GeoDrop with LiveLocation: live position + currently-playing song · 5bbe811c
      Aryan Noshirvnai authored
      GeoDrop was a one-off "drop a song at this exact point" pin, permanent
      once created. Redesigning it as a live broadcast instead: one row per
      user, continuously overwritten as their position and currently-playing
      song change, so nearby people see what you're listening to right now,
      not a static pin you left once.
      
      - LiveLocation model: unique per user_id, upserted on every meaningful
        location/song change plus a periodic heartbeat while sharing is on.
      - PUT /social/live-location - upsert (song_id nullable: sharing your
        position doesn't require actively playing something).
      - DELETE /social/live-location - stop sharing.
      - GET /social/live-location/nearby - other users' live positions within
        a radius, self-excluded, enriched with song/username, sorted by
        distance. Filters out anything not updated in the last 5 minutes
        (LIVE_LOCATION_STALE_AFTER) - there's no reliable way for a closing
        browser tab to notify the server with an authenticated request, so
        staleness expiry is the actual "they stopped sharing" mechanism, not
        a clean disconnect signal.
      - GET /social/live-location/{user_id}/stream - stream whatever a nearby
        user is currently playing, same cross-user reasoning as the other
        social stream endpoints.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      5bbe811c
    • Aryan Noshirvnai's avatar
      Add GET /social/posts/{id}/stream for cross-user post playback · 104986d6
      Aryan Noshirvnai authored
      A post's song_id isn't necessarily the poster's own library song, so
      playing it needed the same not-scoped-to-caller stream endpoint pattern
      already used for rooms, geo-drops, and soundmarks.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      104986d6
    • Aryan Noshirvnai's avatar
      Enrich Posts/GeoDrop responses, validate songs exist, add list/stream endpoints · 77a227a2
      Aryan Noshirvnai authored
      Posts and GeoDrop only ever returned bare song_id/user_id, had no way
      to browse posts at all (only create one or fetch one specific post's
      remix tree by id), and let you create a post/drop referencing a
      nonexistent song_id with no validation.
      
      - GET /social/posts: recent top-level posts (remixes nest under their
        parent via the existing tree endpoint instead), with a remix_count so
        the frontend doesn't need a second call to know if a post has replies.
      - Post/GeoDrop responses now include full song metadata
        (title/artist/album/coverart) and the author's username.
      - create_post/create_geo_drop now 404 if the song (or, for remixes, the
        parent post) doesn't exist instead of silently creating a dangling row.
      - GET /social/geo-drop/{id}/stream: stream a dropped song regardless of
        who uploaded it, mirroring /soundmarks/{id}/stream and
        /social/rooms/{id}/stream's same reasoning - the whole point of a
        drop is someone else finding and playing it.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      77a227a2
    • Aryan Noshirvnai's avatar
      Fix channels.py accepting user_id/owner_id from the request body · f25ef119
      Aryan Noshirvnai authored
      Every route in this router trusted a client-supplied user_id/owner_id
      instead of deriving it from the JWT like every other router in the app
      (soundmarks, social, discovery, library all use get_current_user) - any
      caller could create a channel as any user, follow/unfollow as any user,
      or post vibe-sets/stories/showcases as any user by just changing a
      number in the request body. Also none of the routes required auth at
      all, including plain reads.
      
      Adds get_current_user to every route and derives the caller's identity
      from current_user.id instead, removing the now-redundant id fields from
      every request schema.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      f25ef119
    • Aryan Noshirvnai's avatar
      Add now-playing to live rooms: full song metadata + cross-user streaming · 58f8389f
      Aryan Noshirvnai authored
      Rooms could already chat, react, and request/pass the aux, but nobody
      could actually hear anything - now_playing only ever broadcast a bare
      song_id, there was no way to stream a song you didn't upload yourself
      (the DJ's pick usually isn't the listener's own library song), and the
      DJ could set a nonexistent song_id with no validation.
      
      Adds full song metadata (title/artist/album/coverart) to both the
      snapshot and now_playing_changed broadcasts, validates the song exists
      before setting it, and adds GET /social/rooms/{id}/stream - mirrors
      /soundmarks/{id}/stream's same "shared social content, not scoped to
      the uploader" reasoning - so any room member can actually play what the
      DJ picked.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      58f8389f
  12. 12 Aug, 2026 4 commits
  13. 11 Aug, 2026 3 commits
    • Aryan Noshirvnai's avatar
      Make soundmarks with no anthem yet discoverable via /nearby · 5e02a15d
      Aryan Noshirvnai authored
      Previously /soundmarks/nearby only returned soundmarks that already
      had an active song, so a brand new soundmark (created by a super
      admin, no fallback song_id set, no proposals yet) was invisible to
      the Nearby page - there was no way for anyone to ever discover it and
      make the first proposal. Now it's included with song: null, and the
      webapp shows a "propose one" prompt instead of a play button for that
      case.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      5e02a15d
    • Aryan Noshirvnai's avatar
      Add song proposals + voting to Soundmarks, and a Nominatim geocode proxy · 8b2ac79a
      Aryan Noshirvnai authored
      Users can now propose a song for any soundmark; the most-voted
      proposal is what actually plays there, not just an admin's original
      pick. One vote per (soundmark, user), movable between proposals.
      Directly setting a soundmark's song (business/super admin) now also
      seeds a proposal with the setter's own vote, so it competes fairly
      in the same ranking instead of being a separate, un-votable channel
      that a single stray vote could trivially override - and instead of
      silently losing to the crowd the moment anyone else proposes
      something. Soundmark.song_id remains as the fallback used only while
      a soundmark has zero proposals.
      
      /soundmarks/nearby and /soundmarks/{id}/stream now resolve through
      the same popularity logic, so a soundmark that only has user
      proposals (no admin-set song_id at all) is discoverable and
      streamable too, not just admin-seeded ones.
      
      Also added GET /soundmarks/geocode, a server-side proxy to
      OpenStreetMap's free Nominatim geocoder for the webapp's upcoming
      location-picker autocomplete - proxied because Nominatim's usage
      policy requires a real, identifying User-Agent header, which browser
      JS can't set on a raw fetch().
      
      11 new tests (proposal creation/merging, vote-switching, popularity
      overriding the admin fallback, and the geocode proxy incl. failure
      handling) - 144 backend tests passing overall.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      8b2ac79a
    • Aryan Noshirvnai's avatar
      Add Soundmarks: location-tied anthems with business/super admin roles · 79bdfe8f
      Aryan Noshirvnai authored
      New feature, distinct from the existing GeoDrop (any user dropping a
      song for others to find): a Soundmark is a curated anthem tied to a
      place. One with no owner is a super-admin-curated landmark; one with
      a business_owner_id is that business's location, and only its owner
      (or a super admin) can change its anthem.
      
      - User.role ("user" | "business_admin" | "super_admin") plus
        get_current_business_admin / get_current_super_admin dependencies.
        Super admin passes both checks - same privileges, elevated.
      - New soundmarks router: nearby detection (haversine against each
        soundmark's own trigger radius, not a caller-supplied search
        radius), cross-user anthem streaming (deliberately not scoped to
        the caller owning the underlying song, unlike /library/stream),
        business-owner song assignment, super-admin CRUD, a "public
        library" search across every user's songs (no such cross-user
        endpoint existed before - everything else is locked to the
        caller), and user role management (promote/demote, with owning a
        soundmark auto-promoting a plain user to business_admin so
        ownership isn't otherwise inaccessible to them).
      - GET /auth/me so the webapp can read the caller's role.
      
      25 new tests covering role gating, ownership enforcement, cross-user
      song picking/streaming, and radius-based nearby matching. Promoted
      dev-test-user to super_admin for webapp testing.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      79bdfe8f
  14. 10 Aug, 2026 2 commits
    • Aryan Noshirvnai's avatar
      Skip re-tagging/re-storing a song a user already has in their library · a97f9454
      Aryan Noshirvnai authored
      Previously, re-uploading (or re-tagging from Telegram) a file already
      in your library created a brand new LibrarySong row and a second copy
      of the stored file every time - the IdentifiedTrack cache already
      skipped re-identifying it, but still re-ran ffmpeg tagging and wrote a
      duplicate file, and always inserted a new row. Add a fingerprint
      column to library_songs and check it (per-user) before doing any of
      that: a match now just hands back the existing entry.
      
      Dedup is per-user and keyed by the same content fingerprint already
      used for the IdentifiedTrack cache, not by title/artist text (which
      drifts across correction passes and isn't reliable for this).
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      a97f9454
    • Aryan Noshirvnai's avatar
      Fix the real "can't sync to MPEG frame" cause: mutagen, not ffmpeg · f2a1dce8
      Aryan Noshirvnai authored
      The previous fix (permissive ffmpeg retry on CouldntDecodeError) never
      actually applied to this case - confirmed via the full traceback this time
      (added logger.exception in the prior commit, which paid off immediately):
      the failing file had a .mp3 extension, so it took the "already mp3, just
      copy" fast path entirely, skipping ffmpeg. The actual failure was
      mutagen.mp3.HeaderNotFoundError inside MP3(mp3_file_path, ID3=ID3) - a
      .mp3 extension doesn't guarantee mutagen's strict frame-sync scanner can
      parse the content.
      
      Now: if that direct-copy fast path produces something mutagen can't read,
      re-encode through the same permissive ffmpeg fallback (which sniffs actual
      content, not the extension) and retry once. If even that fails, raises the
      same AudioDecodeError as before for a clean user-facing message instead of
      a raw mutagen exception.
      
      Added tests/test_audio_processing.py with two real (not mocked) cases:
      real WAV audio misnamed as .mp3 (exercises the actual recovery path with
      real audio content) and pure random bytes (confirms genuinely unrecoverable
      input still fails cleanly via AudioDecodeError, not a raw exception).
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      f2a1dce8