now-playing: Navidrome "Listening to" service for Lotus Chat (cinny #491) #68

Merged
jared merged 1 commits from now-playing-service into main 2026-11-16 23:51:08 -05:00
Owner

Backend for LotusGuild/cinny#491 (Discord/Spotify-style "Listening to"). The client side is in the cinny PR.

What it does

now-playing/lotus_now_playing.py: stdlib Python, lotus-now-playing.service, LXC 151 :8072, NPM /now-playing/.

  • Source: polls Navidrome getNowPlaying every 10 s as a non-admin lotus-nowplaying user, direct to 10.10.10.28:4533. Navidrome is the scrobbling master and Dropped Needle passes the listener through (log confirmed user=jared via player="droppedneedle [DroppedNeedleApp]"), so entries carry SSO usernames. The droppedneedle service user is ignored.
  • Auth: Matrix OpenID token → Synapse /_matrix/federation/v1/openid/userinfo (verified to answer locally), cached about 10 min.
  • Matrix → SSO username: the server-only users.json override first (Jeff, Ben and Cole have no email on their SSO link), then the admin API: email <u>@lotusguild.org, or the legacy plain-username external ID. Authelia opaque UUIDs are explicitly ignored.
  • Opt-in: off by default, stored in /var/lib/lotus-now-playing/state.json, written atomically.
  • API:
    • GET/PUT /v1/me
    • GET /v1/users?ids= (up to 50; only opted-in, matched, playing users)
    • GET /v1/cover/<id>: no auth, but only for covers an opted-in user is playing right now
  • Never logs titles, artists or tokens. Request logging is off because paths carry user IDs.

Tests

  • 18 unit tests: python3 -m unittest now-playing/test_lotus_now_playing.py.
  • Local HTTP smoke test (fake Navidrome/Synapse):
    • 401 without a token;
    • empty until opt-in;
    • 400 on a bad PUT;
    • cover 404 until shared and for anyone not sharing;
    • CORS headers present.
  • ruff is clean and now runs on now-playing/ in CI.

Not done yet (needs approval)

  1. Create the Navidrome user lotus-nowplaying (non-admin; navidrome user create) and /etc/lotus-now-playing/env. My attempt was blocked by the permission check.
  2. Write /etc/lotus-now-playing/users.json, run now-playing/install.sh, add the NPM /now-playing/ location (Advanced config plus 49.conf).

🤖 Generated with Claude Code

https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA

Backend for LotusGuild/cinny#491 (Discord/Spotify-style "Listening to"). The client side is in the cinny PR. ## What it does `now-playing/lotus_now_playing.py`: stdlib Python, `lotus-now-playing.service`, LXC 151 `:8072`, NPM `/now-playing/`. - **Source:** polls Navidrome `getNowPlaying` every 10 s as a non-admin `lotus-nowplaying` user, direct to `10.10.10.28:4533`. Navidrome is the scrobbling master and Dropped Needle passes the listener through (log confirmed `user=jared` via `player="droppedneedle [DroppedNeedleApp]"`), so entries carry SSO usernames. The `droppedneedle` service user is ignored. - **Auth:** Matrix OpenID token → Synapse `/_matrix/federation/v1/openid/userinfo` (verified to answer locally), cached about 10 min. - **Matrix → SSO username:** the server-only `users.json` override first (Jeff, Ben and Cole have no email on their SSO link), then the admin API: email `<u>@lotusguild.org`, or the legacy plain-username external ID. Authelia opaque UUIDs are explicitly ignored. - **Opt-in:** off by default, stored in `/var/lib/lotus-now-playing/state.json`, written atomically. - **API:** - `GET`/`PUT /v1/me` - `GET /v1/users?ids=` (up to 50; only opted-in, matched, playing users) - `GET /v1/cover/<id>`: no auth, but only for covers an opted-in user is playing right now - Never logs titles, artists or tokens. Request logging is off because paths carry user IDs. ## Tests - 18 unit tests: `python3 -m unittest now-playing/test_lotus_now_playing.py`. - Local HTTP smoke test (fake Navidrome/Synapse): - 401 without a token; - empty until opt-in; - 400 on a bad PUT; - cover 404 until shared and for anyone not sharing; - CORS headers present. - ruff is clean and now runs on `now-playing/` in CI. ## Not done yet (needs approval) 1. Create the Navidrome user `lotus-nowplaying` (non-admin; `navidrome user create`) and `/etc/lotus-now-playing/env`. My attempt was blocked by the permission check. 2. Write `/etc/lotus-now-playing/users.json`, run `now-playing/install.sh`, add the NPM `/now-playing/` location (Advanced config plus `49.conf`). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
jared added 1 commit 2026-11-16 23:32:18 -05:00
now-playing: Navidrome "Listening to" service for Lotus Chat (cinny #491)
Lint / Shell (shellcheck) (push) Successful in 32s
Lint / JS (eslint) (push) Successful in 27s
Lint / No secrets in webhook configs (push) Successful in 13s
Lint / Python (ruff) (push) Successful in 13s
Lint / Secret scan (gitleaks) (push) Successful in 15s
Lint / Shell (shellcheck) (pull_request) Successful in 19s
Lint / No Hookshot webhook IDs in README (pull_request) Successful in 18s
Lint / JS (eslint) (pull_request) Successful in 24s
Lint / No secrets in webhook configs (pull_request) Successful in 13s
Lint / Landing page is rendered (matrix (pull_request) Successful in 12s
Lint / Python (ruff) (pull_request) Successful in 6s
Lint / Secret scan (gitleaks) (pull_request) Successful in 10s
Lint / Landing page is rendered (matrix (push) Successful in 6s
Lint / Python deps (pip-audit) (pull_request) Successful in 1m50s
Lint / Python deps (pip-audit) (push) Successful in 39s
Lint / No Hookshot webhook IDs in README (push) Successful in 7s
2da017476c
New lotus-now-playing service (LXC 151, :8072, NPM /now-playing/):
- polls Navidrome getNowPlaying every 10 s as a non-admin service user;
  Navidrome is the scrobbling master and Dropped Needle passes the real
  listener through, so entries are keyed by SSO username
- authenticates Lotus Chat with Matrix OpenID tokens (Synapse
  /_matrix/federation/v1/openid/userinfo, cached)
- maps Matrix users to SSO usernames: server-only override file, then the
  Synapse admin API (email <name>@lotusguild.org or the legacy
  plain-username external ID; Authelia opaque UUIDs are ignored)
- opt-in per user (off by default), stored in /var/lib/lotus-now-playing
- GET/PUT /v1/me, GET /v1/users?ids= (opted-in, matched, playing only),
  GET /v1/cover/<id> (no auth, but only covers being played by an
  opted-in user right now)
- never logs titles, artists or tokens

Also: systemd unit, install.sh, unit tests, ruff on now-playing/ in CI,
README section + port row, the outdated NPM note (routes now live in
proxy host 49's Advanced config), and cinny/config.json nowPlaying.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
jared merged commit 3a0a4e15a8 into main 2026-11-16 23:51:08 -05:00
jared deleted branch now-playing-service 2026-11-16 23:51:08 -05:00
Sign in to join this conversation.