now-playing: Navidrome "Listening to" service for Lotus Chat (cinny #491) (#68)
Lint / Shell (shellcheck) (push) Successful in 10s
Lint / JS (eslint) (push) Successful in 7s
Lint / No Hookshot webhook IDs in README (push) Successful in 6s
Lint / No secrets in webhook configs (push) Successful in 6s
Lint / Landing page is rendered (matrix (push) Successful in 7s
Lint / Python (ruff) (push) Successful in 11s
Lint / Python deps (pip-audit) (push) Successful in 36s
Lint / Secret scan (gitleaks) (push) Successful in 5s

This commit was merged in pull request #68.
This commit is contained in:
2026-11-16 23:51:07 -05:00
parent b3fec4af2a
commit 3a0a4e15a8
7 changed files with 767 additions and 3 deletions
+19 -1
View File
@@ -29,6 +29,10 @@ matrix/
├── discord-bridge/
│ ├── config.yaml # mautrix-discord config (DB password filled in on the server, never committed)
│ └── install.sh # One-time installer, run on the Proxmox node hosting LXC 109 + 151
├── now-playing/ # "Listening to" service for Lotus Chat (cinny #491), LXC 151 :8072
│ ├── lotus_now_playing.py
│ ├── test_lotus_now_playing.py
│ └── install.sh
├── deploy/ # Auto-deployment infrastructure
│ ├── lxc151-hookshot.sh # Deploy script for LXC 151 (matrix/hookshot/livekit)
│ ├── lxc106-cinny.sh # Deploy script for LXC 106 (cinny)
@@ -45,6 +49,7 @@ matrix/
├── livekit-graceful-restart.timer # Runs every 5 min
├── draupnir.service
├── mautrix-discord.service # Discord bridge (LXC 151)
├── lotus-now-playing.service # "Listening to" service (LXC 151)
└── cinny-upstream-check.cron # Installed to /etc/cron.d/ on LXC 106 — runs daily at noon
```
@@ -304,6 +309,7 @@ The token in `draupnir/production.yaml` in this repo is **intentionally redacted
| 7881 | LiveKit RTC TCP | 0.0.0.0 |
| 8070 | voice-limit-guard (fronts lk-jwt-service) | 0.0.0.0 |
| 8071 | lk-jwt-service (behind guard) | 127.0.0.1 (matrix #24; was 0.0.0.0) |
| 8072 | lotus-now-playing ("Listening to", cinny #491) | 0.0.0.0 |
| 8080 | synapse-admin (nginx) | 0.0.0.0 |
| 3478 | coturn STUN/TURN | 0.0.0.0 |
| 5349 | coturn TURNS/TLS | 0.0.0.0 |
@@ -381,7 +387,7 @@ Webhook URL format: `https://matrix.lotusguild.org/webhook/<uuid>`
- JS transformation functions use hookshot v2 API: `result = { version: "v2", plain, html, msgtype }`
- The `result` variable must be assigned without `var`/`let`/`const` (QuickJS IIFE sandbox)
- NPM proxies `https://matrix.lotusguild.org/webhook/*` → `http://10.10.10.29:9003`
- NPM proxies `/sfu/get` and `/get_token` → `http://10.10.10.29:8070` (lk-jwt-service). Both paths are in `/data/nginx/proxy_host/49.conf` on LXC 139 — **NPM will overwrite these if proxy host 49 is re-saved via the UI; re-add both location blocks after any NPM save**
- NPM proxies `/sfu/get`, `/get_token` and `/delegate_delayed_leave` → `http://10.10.10.29:8070` (voice-limit-guard → lk-jwt-service), and `/now-playing/` → `:8072`. Since 2026-11-12 all of proxy host 49's custom locations live in its **Advanced** config (NPM sqlite `proxy_host.advanced_config`), so a UI save keeps them. Change them there (or in both the DB and `/data/nginx/proxy_host/49.conf`), never only in the conf file.
- Proxmox sends Discord embed format: `data.embeds[0].{title,description,fields}` — NOT flat fields
- Transform functions are stored as Matrix room state (`uk.half-shot.matrix-hookshot.generic.hook`) and deployed via `hookshot/deploy.sh`
- Hook UUIDs are **not** in that state. Hookshot creates them and keeps a `{uuid: name}` map in the `@hookshot` bot's room account data (same event type). Deploying a new transform creates the hook. To look a UUID up on LXC 151, use the appservice token from `/etc/matrix-synapse/hookshot-registration.yaml`: `GET /_matrix/client/v3/user/@hookshot:matrix.lotusguild.org/rooms/<room>/account_data/uk.half-shot.matrix-hookshot.generic.hook?user_id=@hookshot:matrix.lotusguild.org`
@@ -474,6 +480,18 @@ while the bridge or Synapse was down are bridged when it starts again.
---
## Now Playing ("Listening to", cinny #491)
`now-playing/lotus_now_playing.py` (`lotus-now-playing.service`, LXC 151, `:8072`, NPM `/now-playing/`) gives Lotus Chat what people are playing, for a Discord/Spotify-style "Listening to" card.
- **Source:** Navidrome `getNowPlaying`, polled every 10 s as the non-admin Navidrome user `lotus-nowplaying` (direct to `http://10.10.10.28:4533`). Navidrome is the scrobbling master and Dropped Needle passes the real listener through, so every play shows up under the listener's own Navidrome username, which is their SSO username. Dropped Needle's own `droppedneedle` service user is ignored.
- **Who's asking:** Lotus Chat sends a Matrix OpenID token; the service checks it with Synapse (`/_matrix/federation/v1/openid/userinfo`). Only users of this homeserver can read anything.
- **Matrix user → SSO username:** `/etc/lotus-now-playing/users.json` first (server-only, not in this public repo; for accounts whose SSO link has no email), then the Synapse admin API: an email `<name>@lotusguild.org`, or the legacy plain-username external ID. Uses `MATRIX_TOKEN` from `/etc/matrix-deploy.env`.
- **Opt-in:** off by default; each person turns on "Share what I'm listening to" in Lotus Chat. Stored in `/var/lib/lotus-now-playing/state.json`.
- **API:** `GET`/`PUT /now-playing/v1/me` (`{share, linked, playing}`), `GET /now-playing/v1/users?ids=@a,@b` (up to 50; only opted-in, matched, playing users), and `GET /now-playing/v1/cover/<id>?size=`. The cover endpoint has no auth (for `<img>`) but only serves covers an opted-in user is playing right now.
- Titles, artists and tokens are never logged.
- **Install / update:** create `/etc/lotus-now-playing/env` (`NAVIDROME_USER`, `NAVIDROME_PASSWORD`) once, then `bash /opt/matrix-config/now-playing/install.sh`. Tests: `python3 -m unittest now-playing/test_lotus_now_playing.py`.
## Voice Bridge (nether-voicebridge, Lotus-patched)
Bridges Discord voice into a Lotus voice room. People on Discord appear **inside the Matrix call**