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