Commit 7f2abd19 authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Fix global library search 403ing for non-admin users in Radio

GET /soundmarks/song-library backs SongPicker's "Public Library" tab, which
RadioManageTab's "Add song" reuses for any station owner - but the endpoint
was still gated get_current_business_admin from when only the business/admin
panels used this picker. A plain user got a silent 403 (SongPicker swallows
fetch errors into an empty "No songs found" state), so nothing looked broken,
search just never returned anything. Relaxed to get_current_user, matching
the earlier geocode/reverse-geocode fix for the identical reason - a plain
title/artist search has nothing business-admin-specific about it.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent 3ec09358
Pipeline #1249 canceled with stage
...@@ -302,10 +302,15 @@ def get_my_soundmarks(db: Session = Depends(get_db), current_user: User = Depend ...@@ -302,10 +302,15 @@ def get_my_soundmarks(db: Session = Depends(get_db), current_user: User = Depend
@router.get("/song-library") @router.get("/song-library")
def search_song_library( def search_song_library(
q: str = "", db: Session = Depends(get_db), current_user: User = Depends(get_current_business_admin) q: str = "", db: Session = Depends(get_db), current_user: User = Depends(get_current_user)
): ):
"""The 'public library' business admins pick anthems from - every user's tagged songs, not """The 'public library' search behind SongPicker's "Public Library" tab - every user's
just their own (unlike /library/search, which is scoped to the caller).""" tagged songs, not just their own (unlike /library/search, which is scoped to the caller).
Relaxed from business-admin-only (2026-10-13): originally only business/admin panels used
this picker, but Radio's own queue manager (RadioManageTab) reuses the exact same picker for
any station owner, and there's nothing business-admin-specific about a plain song search -
the business-admin-only panels it originally served still work fine under a user's own
role, since super_admin and business_admin accounts are users too."""
query = db.query(LibrarySong) query = db.query(LibrarySong)
if q: if q:
like = f"%{q}%" like = f"%{q}%"
......
...@@ -327,6 +327,21 @@ def test_song_library_search_spans_all_users(client, db_session, auth_as): ...@@ -327,6 +327,21 @@ def test_song_library_search_spans_all_users(client, db_session, auth_as):
assert {"Alpha Song", "Beta Song"}.issubset(titles) assert {"Alpha Song", "Beta Song"}.issubset(titles)
def test_song_library_search_works_for_any_authenticated_user(client, db_session, auth_as):
# Relaxed from business-admin-only (2026-10-13) - Radio's queue manager reuses the same
# SongPicker "Public Library" tab for any station owner, not just business admins, and a
# plain song search has nothing business-admin-specific about it. Still requires auth.
headers, _ = auth_as()
_make_library_song(db_session, auth_as()[1].id, title="Gamma Song")
response = client.get("/soundmarks/song-library", params={"q": "Gamma"}, headers=headers)
assert response.status_code == 200
assert {s["title"] for s in response.json()["results"]} == {"Gamma Song"}
response = client.get("/soundmarks/song-library", params={"q": "Gamma"})
assert response.status_code == 401
# ---- Suggestions & review queue (major/business tier only) ---- # ---- Suggestions & review queue (major/business tier only) ----
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment