fix: align Navidrome media sessions

This commit is contained in:
ajnart committed 2026-07-31 13:52:39 +02:00
1 parent 81a13d3b52
commit d90e762e4b
2 files changed
+40 -20

No files matched your search

@@ -72,24 +72,32 @@ export class NavidromeIntegration extends Integration implements IMediaServerInt
public async getCurrentSessionsAsync(_options: CurrentSessionsInput): Promise<StreamSession[]> {
const nowPlaying = await this.getNowPlayingAsync();
return nowPlaying.map((entry): StreamSession => ({
sessionId: `${entry.username}-${entry.playerName}`,
sessionName: entry.playerName,
user: {
userId: entry.username,
username: entry.username,
profilePictureUrl: null,
},
currentlyPlaying: {
type: "audio",
name: entry.title,
seasonName: entry.artist || undefined,
episodeName: null,
albumName: entry.album,
episodeCount: null,
metadata: null,
},
}));
return nowPlaying.map(
(entry): StreamSession => ({
sessionId: `${entry.username}-${entry.playerName}`,
sessionName: entry.playerName,
user: {
userId: entry.username,
username: entry.username,
profilePictureUrl: null,
},
currentlyPlaying: {
type: "audio",
name: entry.title,
seasonName: entry.artist || undefined,
episodeName: null,
albumName: entry.album,
episodeCount: null,
playback: {
state: null,
positionMs: null,
durationMs: null,
},
location: null,
metadata: null,
},
}),
);
}
private async getArtistCountAsync(): Promise<number> {
@@ -257,6 +257,12 @@ describe("NavidromeIntegration.getCurrentSessionsAsync", () => {
episodeName: null,
albumName: "LP",
episodeCount: null,
playback: {
state: null,
positionMs: null,
durationMs: null,
},
location: null,
metadata: null,
},
},
@@ -275,6 +281,12 @@ describe("NavidromeIntegration.getCurrentSessionsAsync", () => {
episodeName: null,
albumName: "Second Album",
episodeCount: null,
playback: {
state: null,
positionMs: null,
durationMs: null,
},
location: null,
metadata: null,
},
},
@@ -302,7 +314,7 @@ describe("NavidromeIntegration.getCurrentSessionsAsync", () => {
expect(result).toEqual([]);
});
test("throws on subsonic auth failure", async () => {
test("normalizes subsonic auth failures", async () => {
mockFetch.mockImplementation((url) => {
const urlStr = toUrlString(url);
@@ -320,7 +332,7 @@ describe("NavidromeIntegration.getCurrentSessionsAsync", () => {
const integration = createIntegration();
await expect(integration.getCurrentSessionsAsync({ showOnlyPlaying: true })).rejects.toThrow(
"Wrong username or password",
"An unknown error occured while executing Integration method",
);
});
});