Show what I'm listening to (Dropped Needle / Navidrome) as my Matrix status #491

Closed
opened 2026-11-16 22:45:31 -05:00 by jared · 4 comments
Owner

Request

Let a user link their music player so Lotus Chat sets their Matrix status message to what they're playing, e.g. 🎵 Artist – Track, like Discord's "Listening to". Sources:

What's already there

  • Lotus Chat already sets custom status messages and auto-expires them (#300): src/app/utils/presenceWrite.ts, ownStatusSync.ts, statusExpiry.ts, hooks/usePresenceUpdater.ts, and the settings UI in features/settings/account/Profile.tsx.
  • Dropped Needle (SvelteKit app; no source repo on our Gitea) has its own API: GET /api/v3/now-playing, plus POST /api/v3/scrobble/now-playing, /api/v3/scrobble/submit and /api/v3/me/scrobble-preferences. Its bundle mentions ListenBrainz, so it may already scrobble there.
  • Navidrome 0.64.2: the OpenSubsonic API at https://music.lotusguild.org/rest/* answers without going through the Authelia login (/rest/ping → missing parameter: 'u'). getNowPlaying lists what each user is currently playing.

Possible approaches

  1. In the client (simplest). Add an opt-in setting, "Show what I'm listening to", with a source (Dropped Needle or Navidrome) and that service's login. While Lotus Chat is open it polls now-playing (around every 15–30 s) and sets status_msg through the existing presence write, with an expiry. The status clears when playback stops or the app closes, and it gives way to a manual status or DND if the user has set one.
    • Navidrome: Subsonic token auth (u, t=md5(password+salt), s), then getNowPlaying, keeping only the entry for that user.
    • Dropped Needle: GET /api/v3/now-playing with the user's session or token. Need to check how it authenticates and whether it supports API tokens.
  2. On the server (like lotus-discord-presence). A small service polls both sources for linked users and sets their status. It works even when Lotus Chat is closed, but setting someone's presence needs their own Matrix access token. It would also need its own account-linking flow, which is more moving parts.
  3. Through ListenBrainz. If Dropped Needle and Navidrome both scrobble "playing now" to ListenBrainz, the client only has to read one API (/1/user/<name>/playing-now, no auth). That fits people who already use ListenBrainz.

Starting point I'd suggest: approach 1. Pick the first source by how its auth works: Navidrome's Subsonic token auth is documented and works today; Dropped Needle is easier if it offers API tokens.

Open questions

  • Does Dropped Needle offer per-user API tokens, or only browser sessions? Who maintains it, and can it be changed?
  • Status format, and whether to show it only to people who share a room. Matrix presence is already visible to anyone who shares a room.
  • Should the user's manual status always win over the music one? I'd say yes.
  • Where the user's Navidrome password lives. Store only the salted token in device-local settings, never in account data, because account data syncs to every device.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA

## Request Let a user link their music player so Lotus Chat sets their Matrix status message to what they're playing, e.g. `🎵 Artist – Track`, like Discord's "Listening to". Sources: - **Dropped Needle**: https://droppedneedle.lotusguild.org - **Navidrome**: https://music.lotusguild.org ## What's already there - Lotus Chat already sets custom status messages and auto-expires them (#300): `src/app/utils/presenceWrite.ts`, `ownStatusSync.ts`, `statusExpiry.ts`, `hooks/usePresenceUpdater.ts`, and the settings UI in `features/settings/account/Profile.tsx`. - **Dropped Needle** (SvelteKit app; no source repo on our Gitea) has its own API: `GET /api/v3/now-playing`, plus `POST /api/v3/scrobble/now-playing`, `/api/v3/scrobble/submit` and `/api/v3/me/scrobble-preferences`. Its bundle mentions ListenBrainz, so it may already scrobble there. - **Navidrome 0.64.2**: the OpenSubsonic API at `https://music.lotusguild.org/rest/*` answers without going through the Authelia login (`/rest/ping` → `missing parameter: 'u'`). `getNowPlaying` lists what each user is currently playing. ## Possible approaches 1. **In the client (simplest).** Add an opt-in setting, "Show what I'm listening to", with a source (Dropped Needle or Navidrome) and that service's login. While Lotus Chat is open it polls now-playing (around every 15–30 s) and sets `status_msg` through the existing presence write, with an expiry. The status clears when playback stops or the app closes, and it gives way to a manual status or DND if the user has set one. - Navidrome: Subsonic token auth (`u`, `t`=md5(password+salt), `s`), then `getNowPlaying`, keeping only the entry for that user. - Dropped Needle: `GET /api/v3/now-playing` with the user's session or token. Need to check how it authenticates and whether it supports API tokens. 2. **On the server (like `lotus-discord-presence`).** A small service polls both sources for linked users and sets their status. It works even when Lotus Chat is closed, but setting someone's presence needs their own Matrix access token. It would also need its own account-linking flow, which is more moving parts. 3. **Through ListenBrainz.** If Dropped Needle and Navidrome both scrobble "playing now" to ListenBrainz, the client only has to read one API (`/1/user/<name>/playing-now`, no auth). That fits people who already use ListenBrainz. Starting point I'd suggest: approach 1. Pick the first source by how its auth works: Navidrome's Subsonic token auth is documented and works today; Dropped Needle is easier if it offers API tokens. ## Open questions - Does Dropped Needle offer per-user API tokens, or only browser sessions? Who maintains it, and can it be changed? - Status format, and whether to show it only to people who share a room. Matrix presence is already visible to anyone who shares a room. - Should the user's manual status always win over the music one? I'd say yes. - Where the user's Navidrome password lives. Store only the salted token in device-local settings, never in account data, because account data syncs to every device. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
Author
Owner

Target: behave like Discord + Spotify

Jared's framing: this should work the way Discord handles Spotify. You link your account once. From then on, anyone who looks at you sees a "Listening to" card (track, artist, album art, progress, a link to the track) whenever you're playing, on any device, even if your own Discord client is closed. Setting a text status from my own open client (approach 1 in the issue) only partly does that.

What Dropped Needle actually is (from https://droppedneedle.com/docs)

Correcting the issue body:

  • It's an upstream open-source project (AGPL-3.0, https://github.com/DroppedNeedle/DroppedNeedle), not something we wrote. It's a self-hosted Rust server with its own library, which it serves to Subsonic/Jellyfin apps. It can report plays to Navidrome/Jellyfin/Plex. It has no Discord or Matrix integration of its own.
  • Now playing: GET /api/v3/now-playing returns a live snapshot across all users. There are also /api/v3/playback/{start,progress,stop} and a server-sent event stream for the signed-in user.
  • Auth: session tokens (POST /api/v3/auth/login with "transport":"bearer", then Authorization: Bearer …). There are no long-lived personal API tokens; app passwords only work for the Subsonic/Jellyfin APIs.
  • Plugins: a subscriber plugin gets playback_started and scrobble events, so DN can push events instead of being polled.
  • Scrobbling: ListenBrainz and Last.fm, per user, including "now playing".

A design that matches Discord + Spotify

Matrix presence only carries a text status_msg. There's nowhere to put a rich activity card, and another service can't write someone's presence without that person's own token. So do it on our side:

  1. Lotus "now playing" service (server side, on LXC 151, like lotus-discord-presence).
    • It follows Dropped Needle, either polling the cross-user GET /api/v3/now-playing with one service account or getting pushed events from a small DN subscriber plugin. Navidrome's getNowPlaying (also cross-user, through an admin Subsonic login) works the same way.
    • It keeps a mapping of DN/Navidrome users to Matrix users, set when each user links their account once (see 2).
    • It serves GET /now-playing/<mxid> and a batch version for Lotus Chat: track, artist, album, cover URL, position and duration, and a link back to DN or Navidrome.
  2. Linking, done once in Lotus Chat settings ("Connections → Dropped Needle / Navidrome"). The user proves they own the music account (logs in once). The service stores only the mapping, not the password. Opt-in, and it can be unlinked at any time.
  3. Lotus Chat shows it like Discord does. A "Listening to" card in the user profile and member list, and a small 🎵 line under the name, drawn from the service. It works whether or not the listener has Lotus Chat open.
  4. Fallback for other Matrix clients (optional). If the listener's Lotus Chat is open, it also sets status_msg to 🎵 Artist – Track so Element and other clients see something. The user's own manual status or DND still wins.

What this needs: the service and a DN service account (or a small DN plugin), plus a Lotus Chat settings page and card UI. No Synapse changes. It only covers people who listen through DN or Navidrome; other Matrix clients only get the text fallback.

Questions

  • Use DN's cross-user snapshot with one service account, or write a small DN plugin that pushes events? Polling is simpler; the plugin reacts instantly.
  • Is Navidrome in scope too, or Dropped Needle only?
  • Should "who can see it" be everyone who shares a room with you (like presence), or a narrower setting?

🤖 Generated with Claude Code

https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA

## Target: behave like Discord + Spotify Jared's framing: this should work the way Discord handles Spotify. You link your account once. From then on, anyone who looks at you sees a "Listening to" card (track, artist, album art, progress, a link to the track) whenever you're playing, on any device, even if your own Discord client is closed. Setting a text status from my own open client (approach 1 in the issue) only partly does that. ## What Dropped Needle actually is (from https://droppedneedle.com/docs) Correcting the issue body: - It's an **upstream open-source project** (AGPL-3.0, https://github.com/DroppedNeedle/DroppedNeedle), not something we wrote. It's a self-hosted Rust server with its own library, which it serves to Subsonic/Jellyfin apps. It can report plays to Navidrome/Jellyfin/Plex. It has no Discord or Matrix integration of its own. - **Now playing:** `GET /api/v3/now-playing` returns a live snapshot **across all users**. There are also `/api/v3/playback/{start,progress,stop}` and a server-sent event stream for the signed-in user. - **Auth:** session tokens (`POST /api/v3/auth/login` with `"transport":"bearer"`, then `Authorization: Bearer …`). There are **no long-lived personal API tokens**; app passwords only work for the Subsonic/Jellyfin APIs. - **Plugins:** a `subscriber` plugin gets `playback_started` and `scrobble` events, so DN can push events instead of being polled. - **Scrobbling:** ListenBrainz and Last.fm, per user, including "now playing". ## A design that matches Discord + Spotify Matrix presence only carries a text `status_msg`. There's nowhere to put a rich activity card, and another service can't write someone's presence without that person's own token. So do it on our side: 1. **Lotus "now playing" service (server side, on LXC 151, like `lotus-discord-presence`).** - It follows Dropped Needle, either polling the cross-user `GET /api/v3/now-playing` with one service account or getting pushed events from a small DN `subscriber` plugin. Navidrome's `getNowPlaying` (also cross-user, through an admin Subsonic login) works the same way. - It keeps a mapping of DN/Navidrome users to Matrix users, set when each user links their account once (see 2). - It serves `GET /now-playing/<mxid>` and a batch version for Lotus Chat: track, artist, album, cover URL, position and duration, and a link back to DN or Navidrome. 2. **Linking, done once in Lotus Chat settings** ("Connections → Dropped Needle / Navidrome"). The user proves they own the music account (logs in once). The service stores only the mapping, not the password. Opt-in, and it can be unlinked at any time. 3. **Lotus Chat shows it like Discord does.** A "Listening to" card in the user profile and member list, and a small 🎵 line under the name, drawn from the service. It works whether or not the listener has Lotus Chat open. 4. **Fallback for other Matrix clients (optional).** If the listener's Lotus Chat is open, it also sets `status_msg` to `🎵 Artist – Track` so Element and other clients see something. The user's own manual status or DND still wins. What this needs: the service and a DN service account (or a small DN plugin), plus a Lotus Chat settings page and card UI. No Synapse changes. It only covers people who listen through DN or Navidrome; other Matrix clients only get the text fallback. ## Questions - Use DN's cross-user snapshot with one service account, or write a small DN plugin that pushes events? Polling is simpler; the plugin reacts instantly. - Is Navidrome in scope too, or Dropped Needle only? - Should "who can see it" be everyone who shares a room with you (like presence), or a narrower setting? 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
Author
Owner

Update: use Navidrome as the source

Jared: Navidrome is the scrobbling master (it scrobbles to Last.fm and MusicBrainz). Dropped Needle has its own scrobbling turned off and plays Navidrome's files through the Subsonic API. So every play shows up in Navidrome whichever app it comes from (DN, Symfonium, Feishin…). That simplifies the design:

  • Single source: Navidrome getNowPlaying (OpenSubsonic, https://music.lotusguild.org/rest/getNowPlaying, reachable without Authelia). One service login sees what every user is playing: track, artist, album, cover art id, player name, and how long ago it started. No Dropped Needle integration needed, and no DN plugin.
  • Album art: getCoverArt?id=<coverArt> through the service, so clients never see Navidrome credentials.

Matching Navidrome users to Matrix users

Matrix users log in through Authelia (OIDC, localpart = preferred_username). Navidrome (LXC 104 on compute-storage-gpu-01, 0.64.2) doesn't take its users from SSO: Authelia only guards the web UI. navidrome.toml only sets the music and data folders; /etc/navidrome/lastfm.env only sets Last.fm, with no ND_REVERSEPROXYUSERHEADER. Navidrome keeps its own accounts. Today only 1 of its 5 usernames matches a Matrix localpart exactly. Two ways to handle it:

  1. Switch Navidrome to SSO usernames. Set ND_REVERSEPROXYUSERHEADER=Remote-User and ND_REVERSEPROXYWHITELIST=<NPM IP>/32, with NPM/Authelia forwarding Remote-User for music.lotusguild.org. Navidrome usernames then equal SSO usernames, which equal Matrix localparts, so matching is automatic and nobody has to link anything. Caveat: Navidrome creates a fresh account the first time it sees a name it doesn't know. The 4 existing accounts whose names differ have to be renamed to their SSO username first, or they lose their playlists, stars and history. Subsonic apps (and DN) still sign in with Navidrome passwords; only the web UI changes.
  2. Keep separate accounts and link once. In Lotus Chat settings, the user enters their Navidrome username and password once. The service checks them with ping and stores only the mapping.

Option 1 is cleaner and matches "everyone uses SSO". It's a separate infra change (rename 4 accounts, then set two env vars and an NPM header), to be done before this feature.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA

## Update: use Navidrome as the source Jared: Navidrome is the scrobbling master (it scrobbles to Last.fm and MusicBrainz). Dropped Needle has its own scrobbling turned off and plays Navidrome's files through the Subsonic API. So every play shows up in Navidrome whichever app it comes from (DN, Symfonium, Feishin…). That simplifies the design: - **Single source: Navidrome `getNowPlaying`** (OpenSubsonic, `https://music.lotusguild.org/rest/getNowPlaying`, reachable without Authelia). One service login sees what every user is playing: track, artist, album, cover art id, player name, and how long ago it started. No Dropped Needle integration needed, and no DN plugin. - Album art: `getCoverArt?id=<coverArt>` through the service, so clients never see Navidrome credentials. ## Matching Navidrome users to Matrix users Matrix users log in through Authelia (OIDC, localpart = `preferred_username`). Navidrome (LXC 104 on compute-storage-gpu-01, 0.64.2) **doesn't take its users from SSO**: Authelia only guards the web UI. `navidrome.toml` only sets the music and data folders; `/etc/navidrome/lastfm.env` only sets Last.fm, with no `ND_REVERSEPROXYUSERHEADER`. Navidrome keeps its own accounts. Today only 1 of its 5 usernames matches a Matrix localpart exactly. Two ways to handle it: 1. **Switch Navidrome to SSO usernames.** Set `ND_REVERSEPROXYUSERHEADER=Remote-User` and `ND_REVERSEPROXYWHITELIST=<NPM IP>/32`, with NPM/Authelia forwarding `Remote-User` for music.lotusguild.org. Navidrome usernames then equal SSO usernames, which equal Matrix localparts, so matching is automatic and nobody has to link anything. **Caveat:** Navidrome creates a fresh account the first time it sees a name it doesn't know. The 4 existing accounts whose names differ have to be renamed to their SSO username first, or they lose their playlists, stars and history. Subsonic apps (and DN) still sign in with Navidrome passwords; only the web UI changes. 2. **Keep separate accounts and link once.** In Lotus Chat settings, the user enters their Navidrome username and password once. The service checks them with `ping` and stores only the mapping. Option 1 is cleaner and matches "everyone uses SSO". It's a separate infra change (rename 4 accounts, then set two env vars and an NPM header), to be done before this feature. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
Author
Owner

Correction: no Navidrome renames needed

My last comment compared Navidrome usernames to Matrix localparts. That was the wrong comparison: many Matrix accounts are older than SSO and have different localparts. A dry run against the real SSO directory (LLDAP) shows Navidrome usernames already equal the SSO usernames (jared, jeff, othernathan, spencer; plus droppedneedle, Dropped Needle's own service account). Ignore "option 1 / rename 4 accounts".

How to match users

Navidrome username = SSO username → Matrix account:

  • Synapse user_external_ids (auth_provider = oidc-authelia) holds Authelia's opaque subject UUID for each Matrix user, not the username.
  • Authelia's user_opaque_identifier table (/etc/authelia/db.sqlite, LXC 167) maps that UUID to the SSO username.
  • One legacy row uses provider https://auth.lotusguild.org with the plain username as external_id.
  • 10 of the 18 Matrix users are linked to SSO today. Users without a link can't be matched and need a one-time link in settings.

The service can build this map at startup and refresh it every so often (read-only on both DBs). Or Lotus Chat can send the user's SSO username when they opt in, and the service checks it against the same tables.

Open issue: Dropped Needle plays may be credited to one account

DN logs in to Navidrome with a single droppedneedle account (last active today, while the personal Navidrome accounts were last used months ago). If so, Navidrome's getNowPlaying shows DN plays under droppedneedle, not the listener. DN has its own Authelia OIDC client, so its users are SSO users and its GET /api/v3/now-playing (cross-user) does know who's listening. If that's confirmed, the service needs both feeds:

  • Navidrome getNowPlaying for plays from Subsonic apps, skipping the droppedneedle entries;
  • Dropped Needle GET /api/v3/now-playing for plays in DN.

To confirm: play something in DN and look at getNowPlaying at the same time.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA

## Correction: no Navidrome renames needed My last comment compared Navidrome usernames to **Matrix localparts**. That was the wrong comparison: many Matrix accounts are older than SSO and have different localparts. A dry run against the real SSO directory (LLDAP) shows **Navidrome usernames already equal the SSO usernames** (`jared`, `jeff`, `othernathan`, `spencer`; plus `droppedneedle`, Dropped Needle's own service account). Ignore "option 1 / rename 4 accounts". ## How to match users Navidrome username = SSO username → Matrix account: - Synapse `user_external_ids` (`auth_provider = oidc-authelia`) holds Authelia's **opaque subject UUID** for each Matrix user, not the username. - Authelia's `user_opaque_identifier` table (`/etc/authelia/db.sqlite`, LXC 167) maps that UUID to the SSO username. - One legacy row uses provider `https://auth.lotusguild.org` with the plain username as `external_id`. - 10 of the 18 Matrix users are linked to SSO today. Users without a link can't be matched and need a one-time link in settings. The service can build this map at startup and refresh it every so often (read-only on both DBs). Or Lotus Chat can send the user's SSO username when they opt in, and the service checks it against the same tables. ## Open issue: Dropped Needle plays may be credited to one account DN logs in to Navidrome with a single `droppedneedle` account (last active today, while the personal Navidrome accounts were last used months ago). If so, Navidrome's `getNowPlaying` shows DN plays under `droppedneedle`, not the listener. DN has its own Authelia OIDC client, so its users are SSO users and its `GET /api/v3/now-playing` (cross-user) does know who's listening. If that's confirmed, the service needs both feeds: - Navidrome `getNowPlaying` for plays from Subsonic apps, skipping the `droppedneedle` entries; - Dropped Needle `GET /api/v3/now-playing` for plays in DN. To confirm: play something in DN and look at `getNowPlaying` at the same time. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
Author
Owner

Resolved: Navidrome alone is enough

Jared changed Dropped Needle so it passes the listener through to Navidrome. Navidrome's log on 2026-11-16 confirms it:

  • before the change: msg="Now Playing" player="droppedneedle [DroppedNeedleApp]" … user=droppedneedle
  • after it (23:00): msg="Now Playing" artist="Maroon 5" player="droppedneedle [DroppedNeedleApp]" title=Animals user=jared, and scrobbles are now logged with user=jared

So Navidrome getNowPlaying is the only feed needed, already credited to the right SSO username, whatever app the music is played from (DN or Subsonic apps). Drop the "DN GET /api/v3/now-playing" part of the previous comment. Match users as described there (Navidrome username = SSO username → Authelia opaque ID → Synapse user_external_ids).

The service needs its own Navidrome login (a dedicated non-admin account) to call getNowPlaying. Check that a non-admin account still sees other users' entries.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA

## Resolved: Navidrome alone is enough Jared changed Dropped Needle so it passes the listener through to Navidrome. Navidrome's log on 2026-11-16 confirms it: - before the change: `msg="Now Playing" player="droppedneedle [DroppedNeedleApp]" … user=droppedneedle` - after it (23:00): `msg="Now Playing" artist="Maroon 5" player="droppedneedle [DroppedNeedleApp]" title=Animals user=jared`, and scrobbles are now logged with `user=jared` So **Navidrome `getNowPlaying` is the only feed needed**, already credited to the right SSO username, whatever app the music is played from (DN or Subsonic apps). Drop the "DN `GET /api/v3/now-playing`" part of the previous comment. Match users as described there (Navidrome username = SSO username → Authelia opaque ID → Synapse `user_external_ids`). The service needs its own Navidrome login (a dedicated non-admin account) to call `getNowPlaying`. Check that a non-admin account still sees other users' entries. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
jared closed this issue 2026-11-16 23:55:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/cinny#491