Settings column and now-playing state table (phase 4, step 1)
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m9s
CI / test (push) Successful in 3m5s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s

federation_settings gains now_playing_mode (off/profile/posts,
default off), validated in sharing.update() the same way visibility
is. New federation_now_playing table: one row per user, tracking what
we've last told the fediverse (profile_key/profile_updated_at,
post_key/post_posted_at) - separate from core's now_playing table,
which is what's actually playing right now.

Verified the migration both ways against the local dev database: full
downgrade to base and back up to heads on both branches, not just a
single-step round trip.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
mattandClaude Sonnet 5 committed 2026-09-26 16:57:34 +01:00
1 parent 7d86bad929
commit cb8f9c997e
4 files changed
+80 -6

No files matched your search

+5 -1
View File
@@ -2,7 +2,7 @@
from scrobbler.extensions import db
from scrobbler.federation import keys
from scrobbler.federation.models import VISIBILITIES, FederationSettings
from scrobbler.federation.models import NOW_PLAYING_MODES, VISIBILITIES, FederationSettings
from scrobbler.federation.protocol.schedule import is_valid_timezone
from scrobbler.services import accounts
@@ -17,6 +17,7 @@ EDITABLE = (
"timezone",
"post_weekly_summary",
"post_milestones",
"now_playing_mode",
)
@@ -36,6 +37,7 @@ def settings_for(user_id: int) -> FederationSettings:
timezone="UTC",
post_weekly_summary=True,
post_milestones=True,
now_playing_mode="off",
)
return settings
@@ -48,6 +50,8 @@ def update(user_id: int, changes: dict) -> tuple[FederationSettings, bool | None
raise ValueError(f"not editable: {sorted(unknown)}")
if changes.get("visibility", "followers") not in VISIBILITIES:
raise ValueError("visibility must be one of " + ", ".join(VISIBILITIES))
if changes.get("now_playing_mode", "off") not in NOW_PLAYING_MODES:
raise ValueError("now_playing_mode must be one of " + ", ".join(NOW_PLAYING_MODES))
if "timezone" in changes and not is_valid_timezone(changes["timezone"]):
raise ValueError(f"not a known time zone: {changes['timezone']!r}")
settings = settings_for(user_id)