Fix: never show now-playing when now_playing_mode is off
CI / validate-monitoring (push) Successful in 9s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m7s
CI / test (push) Successful in 3m3s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
CI / validate-monitoring (push) Successful in 9s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m7s
CI / test (push) Successful in 3m3s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
now_playing_field() read core's now_playing table unconditionally, so a user who never turned federation's now-playing feature on at all would still leak what they're currently listening to on their public actor document, since core's now_playing table is populated for every user regardless of federation settings. Found while designing step 3 (the periodic push task): querying only sharing users with now_playing_mode != "off" made me notice build_document() itself had no equivalent guard, and the existing tests happened not to catch it (they only combined "nothing playing" with "mode off", and "something playing" with "mode on"). Added the missing combination - something playing, mode off - to both the actors.py unit tests and the web-level actor route test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
c38e2e392a
commit
9ab8bd8e03
3 files changed
+34
-3
No files matched your search
@@ -72,6 +72,7 @@ def test_actor_document(fed_client, sharing_user):
|
||||
def test_actor_document_shows_now_playing_live(fed_client, fed_ctx, sharing_user):
|
||||
from scrobbler.services.scrobbles import TrackInput, update_now_playing
|
||||
|
||||
sharing.update(sharing_user.id, {"now_playing_mode": "profile"})
|
||||
update_now_playing(sharing_user, TrackInput(artist="Radiohead", track="Reckoner"))
|
||||
doc = fed_client.get("/users/alice", headers=AP).get_json()
|
||||
assert doc["attachment"] == [
|
||||
@@ -79,6 +80,16 @@ def test_actor_document_shows_now_playing_live(fed_client, fed_ctx, sharing_user
|
||||
]
|
||||
|
||||
|
||||
def test_actor_document_never_shows_now_playing_when_the_mode_is_off(
|
||||
fed_client, fed_ctx, sharing_user
|
||||
):
|
||||
from scrobbler.services.scrobbles import TrackInput, update_now_playing
|
||||
|
||||
update_now_playing(sharing_user, TrackInput(artist="Radiohead", track="Reckoner"))
|
||||
doc = fed_client.get("/users/alice", headers=AP).get_json()
|
||||
assert doc["attachment"] == []
|
||||
|
||||
|
||||
def test_ids_come_from_config_not_the_request(fed_client, sharing_user):
|
||||
doc = fed_client.get("/users/alice", headers={**AP, "Host": "evil.example"}).get_json()
|
||||
assert urlsplit(doc["id"]).netloc == "scrobble.test"
|
||||
|
||||
Reference in new issue
Block a user