feat(presence): "Listening to" from Navidrome / Dropped Needle (#491)
CI / Build & Quality Checks (push) Skipped
CI / Secret scan (gitleaks) (push) Skipped
CI / Playwright smoke (e2e) (push) Skipped
CI / Build & Quality Checks (push) Skipped
CI / Secret scan (gitleaks) (push) Skipped
CI / Playwright smoke (e2e) (push) Skipped
Discord/Spotify-style now playing, served by the new Lotus now-playing service (matrix repo, now-playing/): - Profile popout: a "Listening to" card (cover, track, artist, album, live progress); member list: a 🎵 line when the member has no typed status. Data comes from GET /now-playing/v1/users, batched across all visible users and polled every 20 s while the page is visible. - Settings → Profile: "Share what I'm listening to", off by default, stored by the service (GET/PUT /v1/me). Auth is a Matrix OpenID token. - Status text: while Lotus is open and sharing, the Matrix status shows "🎵 Artist – Track" so other clients see it, but only when the user has no typed status, and never in DND/Invisible. The typed status and its auto-clear are never touched. The music text uses a thin space after the note, and every device reads it as "no typed status" (pickHeartbeatStatus, Profile sync), so it can't be adopted as the user's status. Clearing or auto-clearing a status falls back to the music; closing the window drops it (pagehide sends the typed status). - config.json: nowPlaying → https://matrix.lotusguild.org/now-playing. Tests: nowPlaying.test.ts (format, marker, priority matrix, position, config/cover URLs) and a heartbeat case in ownStatusSync.test.ts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { LOCAL_WRITE_GRACE_MS, pickHeartbeatStatus } from './ownStatusSync';
|
||||
import { NOW_PLAYING_PREFIX } from './nowPlaying';
|
||||
|
||||
const now = 1_000_000;
|
||||
const old = { lastLocalWriteAt: 0, now };
|
||||
@@ -79,3 +80,40 @@ test('pickHeartbeatStatus: the "dnd" sentinel is never adopted as the user statu
|
||||
'new',
|
||||
);
|
||||
});
|
||||
|
||||
test('[Gitea #491] music text on the server is never adopted as a typed status', () => {
|
||||
const music = `${NOW_PLAYING_PREFIX}Maroon 5 – Animals`;
|
||||
// Music is only published with no typed status, so it reads as "none" —
|
||||
// including when another device has since cleared the typed status.
|
||||
assert.equal(
|
||||
pickHeartbeatStatus({ ...old, local: '', server: { presence: 'online', status_msg: music } }),
|
||||
'',
|
||||
);
|
||||
assert.equal(
|
||||
pickHeartbeatStatus({
|
||||
...old,
|
||||
local: 'cleared elsewhere',
|
||||
server: { presence: 'online', status_msg: music },
|
||||
}),
|
||||
'',
|
||||
);
|
||||
// A fresh local save still wins over a server read showing the old music.
|
||||
assert.equal(
|
||||
pickHeartbeatStatus({
|
||||
local: 'studying',
|
||||
server: { presence: 'online', status_msg: music },
|
||||
lastLocalWriteAt: now - 1000,
|
||||
now,
|
||||
}),
|
||||
'studying',
|
||||
);
|
||||
// A status the user typed that merely starts with 🎵 is theirs.
|
||||
assert.equal(
|
||||
pickHeartbeatStatus({
|
||||
...old,
|
||||
local: '',
|
||||
server: { presence: 'online', status_msg: '🎵 vibes' },
|
||||
}),
|
||||
'🎵 vibes',
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user