Users can upload, fetch and remove a profile image at /api/v1/me/avatar. The
bytes live in an avatars folder inside ART_STORAGE_DIR; the users row records the
source and content type. Adds metrics, AVATAR_UPLOAD_MAX_BYTES and the regenerated
OpenAPI document.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The design repo now ships a finished wordmark, so the header uses it (one file
per colour scheme) instead of live Bricolage text, and the font is dropped.
The artwork is all rights reserved, so it gets its own licence file.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Display name only: UI, docs, API title, dashboards, hashtag and User-Agent.
Identifiers (package, metrics, env vars, SCROBBLER_CONFIG) are unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Corrections accept a release MBID as well as a release-group MBID, and the
worker uses a scrobble's recording MBID to find the release-group before falling
back to the text search. Counts matched/missed recording lookups.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Shared LOG_LEVEL/LOG_FORMAT (text or json) set up in create_app, per-task
activity and duration logs in the worker, and more context on delivery,
inbox and import failures. Alembic's fileConfig no longer disables loggers.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Let Docker allocate each run's network subnet instead of deriving a /24 from
the run number, trust private ranges in GoToSocial, and tag/clean up api and ui
images per run so overlapping runs (e.g. main push plus tag) cannot collide.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Uploads and queued corrections are stored per user and take precedence over the
global cache; the worker resolves corrections (by MusicBrainz release-group or
corrected search text) ahead of the global queue. Adds upload/correction metrics
and DB gauges for overrides and the unresolved-album backlog.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHPkt2v797pphGCFKfTFmv
Endpoint result counters, worker resolution/latency/image-size metrics,
per-upstream latency and error counters, cache-status and oldest-pending
gauges, an Album Art Grafana dashboard, and backlog/upstream-error alerts.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHPkt2v797pphGCFKfTFmv
Stops album art lookups from blocking page loads: the art endpoint is
now cache-only (never calls MusicBrainz/Cover Art Archive in the
request path), a background worker task resolves and downloads art
asynchronously, and resolved images are cached on a disk volume
instead of re-fetched on every view.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Hn2QwS1HRT8tFAzo8ew63
Root cause: gunicorn runs only 2 sync workers, and GET /api/v1/art/album
did its MusicBrainz + Cover Art Archive work synchronously inside the
request (2-12+ seconds per call, measured). A page with several
uncached albums could tie up the entire application - every endpoint,
every user - for as long as that took. Separately, even an
already-resolved album re-streamed its image bytes live from Cover
Art Archive on every single page view, by the original v1 design.
The endpoint is now cache-only: it reads the album_art table and, if
resolved, a local file, and never touches the network. A cache miss
records a "pending" row and returns 404 immediately - the frontend
already treats 404 as "show the placeholder," so no frontend changes
are needed. A new background worker task (the same claim-with-
FOR-UPDATE-SKIP-LOCKED pattern already used by imports and federation
deliveries) does the actual resolving and downloads the image bytes
to a shared volume, completely decoupled from any request. No
migration needed: AlbumArt.status just gains a new "pending" value.
Verified against the real docker compose stack (not just the test
suite): cold lookups for 5 real albums all returned 404 in well under
0.2s (previously 2-12+s each), the worker resolved all 5 within ~10s
in the background, and resolved art then served in single-digit
milliseconds from the volume, including after a full container
restart (no re-download).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Hn2QwS1HRT8tFAzo8ew63
Note objects can now carry an optional attachment (an AS2 Image),
which Mastodon and other AP servers render as the post's media. Only
"now playing" posts use it for now - it's the only post type tied to
a single track, and therefore the only one with one unambiguous
album; weekly summaries and milestones aggregate many tracks.
The attachment points straight at the Cover Art Archive URL cached
in AlbumArt, not our own authenticated /api/v1/art/album proxy - a
remote server fetches attachments unauthenticated, and Cover Art
Archive is already public. The lookup happens in the periodic
now-playing worker task, not a request, so a cache-miss MusicBrainz/
Cover Art Archive call adds no request latency.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Hn2QwS1HRT8tFAzo8ew63
- art.js revoked each thumbnail's blob: URL on its own "load" event,
but the same URL is shared (via the lookup cache) by every
thumbnail for that album on the page - revoking after the first
one loaded broke every other <img> still using it. Stop revoking;
this is a full-page-reload site, so the browser releases the
memory on navigation anyway.
- .ranking-art/.log-art thumbnails inherited their row's default
cross-axis alignment (baseline for .ranking, stretch for .log),
which suits text but left the art sitting high against two-line
name+artist text. Center them explicitly instead.
Verified in-browser across all four surfaces (song page hero,
dashboard Albums ranking, Recently played, History) with real
MusicBrainz/Cover Art Archive artwork.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Hn2QwS1HRT8tFAzo8ew63
New frontend/js/art.js builds a thumbnail that starts as a placeholder
and swaps itself for the real cover once (if) it resolves, fetched
via the new /api/v1/art/album endpoint with the existing bearer-auth
transport and handed to the browser as a blob: object URL (no
query-string tokens, no hotlinking).
Wired into all four places a track/album appears: the song page's
glowing display, the dashboard's "Most played > Albums" list, the
dashboard's "Recently played" list, and the full History page -
Artists/Tracks rankings are left alone.
Also fixes a real reliability gap found during manual testing:
Cover Art Archive's existence check (a HEAD request, redirected
through archive.org) had no retry at all, unlike the MusicBrainz
search next to it, and an occasional slow/flaky response there was
enough to fail a lookup outright. It now retries the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
New GET /api/v1/art/album?artist=&album= resolves and streams an
album's cover art. Lookups go through MusicBrainz release-group
search then Cover Art Archive's release-group front-image endpoint,
both free and keyless - no setup required by self-hosters. Results
(hits, misses and errors) are cached in a new album_art table keyed
case-insensitively on (artist, album), since Scrobble.mbid can't be
trusted as a release identifier.
The service layer separates resolving where the art is (lookup())
from fetching the bytes (fetch_image()) so a future move to storing
the bytes ourselves only touches the latter.
Also widens the UI's CSP (img-src) to allow blob: URLs, since the
frontend will fetch art with the existing bearer-auth header and
hand the browser a blob: object URL rather than hotlinking.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Stack the track above a muted artist line and link each row to its
song page, consistent with how the "Most played > Tracks" list
already looks and behaves. Scoped with a new .log-stacked modifier
so history.html and the song page's own history list (which share
the base .log classes) are unaffected.
Verified manually in-browser: rows render stacked and link to the
right song page, and history.html's layout is unchanged.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Previously the song page was a plain heading, a bare metadata list
and a history log. Now it gets its own moment on the glowing
amber display, reusing the dashboard's .panel/.display/.readouts/
.spectrum components verbatim: the track name lit up like a
now-playing display, play/first-played/last-played readouts, and a
90-day per-track play-activity chart.
Extracted the segmented spectrum chart out of dashboard.js into a
shared frontend/js/spectrum.js so both pages use the same renderer;
the dashboard's own output is unchanged.
Verified manually in-browser: the panel renders correctly, an
artist name with a slash round-trips, the not-found and
no-query-params states render into the panel, and the dashboard's
spectrum chart is pixel-for-pixel unchanged after the extraction.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Scopes listen_counts() to a single artist/track, the same way
recent() was scoped for song history, so the song page can drive a
per-track activity chart over the last 90 days.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
New song.html shows a song's aggregated metadata and full play
history (paginated), reached from the dashboard via a debounced
search box or by clicking a track in the "Most played" list.
Verified manually in-browser: search, click-through from Most played
(including an artist name with a slash), the not-found and
no-query-params states, and the pager.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
New GET /api/v1/me/tracks/search finds songs by track or artist name;
GET /api/v1/me/tracks returns a song's aggregated metadata (album,
duration, mbid, etc. - most common non-null value per field) plus its
paginated scrobble history, identified by artist+track query params
since there's no normalized Track model.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
test_preview_weekly_reflects_the_week_in_progress hardcoded its
scrobble at noon UTC on "this week's Monday", but the preview window
is [week start, now) - so it failed for real whenever CI ran before
noon UTC on a Monday (as it just did in run 624). Use now - 1 minute
instead, which is always inside the window regardless of what time
the test runs.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
Top albums were already available from the API (/me/top/albums, same
shape as artists/tracks) but never surfaced in the UI. Reuses the
existing renderRanking() helper; the charts grid is auto-fit, so the
third column drops in with no CSS changes.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
Renames deploy.md -> admin-guide.md and usage.md -> user-guide.md, and expands
each with content aimed squarely at its audience: the admin guide gains an
upgrade procedure, a restore procedure, an nginx+certbot TLS example, and a
troubleshooting section built from real issues hit during manual testing
(CORS_ORIGINS vs UI_BASE_URL, the sharing nav's browser-cache lag, and
mastodon.social's negative WebFinger caching); the user guide gains a getting-
started section and a matching end-user-facing troubleshooting section.
setup.md is unchanged apart from updated cross-links.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
After images publish for a v* tag, call the Gitea API to dispatch
ScrobbledDeploy's deploy workflow with the released version, so a
tagged release automatically redeploys the app tier.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Followable from Mastodon and other fediverse apps: discoverable
profiles, followers, weekly summaries, milestones, now playing (a
live profile field plus opt-in posts), and the web UI and settings
for all of it. Off by default at the server level, and off per user
until they turn sharing on.
Verified with a GoToSocial container in CI on every push throughout,
and with a manual pass against a real Mastodon account and
activitypub.academy over a public HTTPS tunnel before this merge.
See docs/design/activitypub.md and the phase-by-phase design docs
alongside it for the full design and build history.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
README had grown into one long file covering deployment, local
development and end-user features together. Split into:
- docs/deploy.md: running a real instance - images, configuration,
putting it behind TLS (with a minimal Caddy example and the
CORS_ORIGINS/UI_BASE_URL distinction the last session's manual test
found the hard way), monitoring, backups, releases.
- docs/setup.md: working on the code - local dev environment,
migrations, tests, the manual fediverse test, CI/CD.
- docs/usage.md: accounts and apps, connecting a player, importing
history, sharing on the fediverse.
README is now a short overview and quick start that links to the
three, plus the existing API reference and federation/design docs.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
Ran the manual pass with a real Mastodon account through a cloudflared
tunnel - the one gap every phase doc had flagged as outstanding before
merging. WebFinger, actor resolution, follow/unfollow/approve/block,
a forced weekly summary posting and deleting, and the now-playing
profile field appearing/clearing all worked correctly against
mastodon.social and activitypub.academy.
Two real bugs found along the way, both fixed here:
- docker-compose.yml hardcoded the api/worker services' CORS_ORIGINS
to UI_BASE_URL. Pointing UI_BASE_URL at the tunnel host (needed for
federation's own identity) silently changed which browser origins
the API accepted, blocking the operator's own localhost:8080 UI -
.env's own CORS_ORIGINS setting had no effect, since the compose
file never referenced it. Now its own variable, same default.
- TestConfig wasn't isolating UI_BASE_URL/CORS_ORIGINS from a
developer's .env, so the same local change broke six tests that
assert on http://localhost:8080 URLs - the same class of gap an
earlier session found and fixed for FEDERATION_ENABLED/
LASTFM_API_KEY. Pinned alongside them.
Marked the manual pass done in each phase doc (1-4) and the overview.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
README: the Sharing page's Now playing section, its three modes and
their throttles.
federation/README.md: now_playing.py added to the publishing
plug-ins list (with a note on why it's not quite the same shape as
weekly.py/milestones.py - a periodic scan covering both the profile
push and the opt-in post, rather than an event receiver), actors.py
added to the layout table, and the worker tasks / interop sections
updated for federation.now_playing and the new profile-field check.
docs/design/activitypub-phase4.md marked done, with the two points
where implementation diverged from the written plan (the key-hashing
fix and the now_playing_mode privacy gate).
docs/openapi.json unchanged - still current from step 4.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
Extends the GoToSocial driver's second phase: run.sh seeds a
now-playing track alongside the scrobble it already seeds for the
weekly summary; the driver turns now_playing_mode on via the settings
API, then polls GoToSocial's own stored copy of the account (not a
fresh resolve() fetch) for a "Now playing" field, confirming the
periodic Update(Person) push actually reached and updated their cache
- not just that we sent something.
Verified against a real GoToSocial 0.22.1 container locally before
pushing:
Now playing: 'Interop Now Playing by Interop Artist'
All post interop checks passed
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
One new panel on the Federation dashboard's existing Posts row:
profile updates/min by result (sent/throttled). now_playing posts
already show up in the Posts / min by kind panel from phase 3, under
kind="now_playing" - no changes needed there.
No new alert: unlike weekly summaries, now playing is opt-in and most
instances will have nobody using it, so there's no "should always be
producing something" baseline to alert on the way
FederationWeeklySummariesMissing does.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
Sharing page gets a "Now playing" section: off / show on profile /
show on profile and post, as a single choice matching the settings
column - generalised sharing.js's visibility-only radio-group handling
to a small RADIO_GROUPS list so now_playing_mode reuses the same fill/
save logic rather than adding a second special case.
Public profile API and profile.html gain a live "now playing" field,
sourced from the same actors.now_playing_text() the actor document
uses and gated the same way (now_playing_mode off means never showing
it, whatever's actually playing).
Refactored actors.py along the way: now_playing_field() takes settings
directly and does its own off-mode gating, rather than build_document()
doing it externally - one place decides whether the field is shown,
reused by the actor document, the push Update, and now the public
profile API.
Verified by hand in a real browser: settings round-trip through the
Sharing page's new radio group, the public profile page shows "Now
playing: Reckoner by Radiohead" once now_playing_mode is on, and the
raw actor document (curl, Accept: application/activity+json) carries
the same PropertyValue attachment.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
now_playing_mode was already in sharing.EDITABLE (step 1), so
_settings_body() was already returning it - but SharingSettingsSchema
never declared the field, so marshmallow was silently dropping it from
every response. Same class of gap phase 3 hit with timezone/
post_weekly_summary/post_milestones.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
publishing/now_playing.py: a periodic scan (federation.now_playing,
every 30s) that pushes a throttled Update(Person) for the profile
field (5 minutes) and, for users opted into posts, publishes a Note
after a track's been playing 30+ seconds (throttled to 30 minutes),
deleting the previous now-playing post once the new one is confirmed
published - not before, so a failed publish never leaves a user with
none showing. Reuses publishing.publish()/delete_post() unchanged;
now_playing is just another post kind.
Fixed a real bug before it ever ran against Postgres: the key
(artist/track/started_at) was going straight into federation_posts.key
(VARCHAR(64)), which routinely overflows for real track and artist
names. Hashed instead - it's an idempotency token, not something
anyone needs to read.
New metric scrobbler_federation_profile_updates_total{result}; posts
already get scrobbler_federation_posts_total{kind="now_playing",...}
for free from the existing publish() instrumentation.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
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
vocab.update() wraps a document as an Update, addressed explicitly
(unlike undo(), which derives `to` from the undone activity - an actor
document has no `to` of its own).
New actors.py builds the actor document body, shared by GET /users/<u>
(live) and the coming Update(Person) push (throttled) so both render
the same shape without web.py depending on the worker-side module or
vice versa. now_playing_field() reads core's get_now_playing()
directly - never federation's own throttled push state - so a fetch
always shows the truth, whatever the last proactive push said.
GET /users/<u> now includes a "Now playing" PropertyValue attachment
whenever something unexpired is playing, and omits it otherwise.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
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