feat(subsonic): wire /rest/scrobble into playevents.Writer
submission=false → play_started (replaces in-memory nowPlayingMap). submission=true (default) → synthetic completed play. The nowPlayingMap struct + factory + the nowPlaying field on mediaHandlers are deleted; play_events WHERE ended_at IS NULL is now the source of truth for 'currently playing,' reachable from M3+ work. api.Mount now takes the shared *playevents.Writer instead of cfg so the same writer instance feeds both surfaces.
This commit is contained in:
@@ -4,8 +4,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
func TestFindSidecarCover(t *testing.T) {
|
||||
@@ -53,26 +51,3 @@ func TestImageContentType(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNowPlayingMap(t *testing.T) {
|
||||
m := newNowPlayingMap()
|
||||
user := "user-1"
|
||||
if _, ok := m.Get(user); ok {
|
||||
t.Fatalf("unexpected entry on fresh map")
|
||||
}
|
||||
|
||||
var trackID pgtype.UUID
|
||||
_ = trackID.Scan("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
|
||||
m.Set(user, trackID)
|
||||
|
||||
entry, ok := m.Get(user)
|
||||
if !ok {
|
||||
t.Fatalf("Set did not persist")
|
||||
}
|
||||
if uuidToID(entry.TrackID) != "6ba7b810-9dad-11d1-80b4-00c04fd430c8" {
|
||||
t.Errorf("trackID round-trip broke: %q", uuidToID(entry.TrackID))
|
||||
}
|
||||
if entry.At.IsZero() {
|
||||
t.Errorf("At timestamp not set")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user