From 58adb991f263a4f89fa999fc8a4aadbf4ead7384 Mon Sep 17 00:00:00 2001 From: Matthew Haughton <3flex@users.noreply.github.com> Date: Sun, 10 Nov 2024 23:20:08 +1100 Subject: [PATCH 1/2] Stop unnecessarily passing userId in API calls --- src/components/documentManager.ts | 3 +-- src/components/jellyfinActions.ts | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/components/documentManager.ts b/src/components/documentManager.ts index 3be420d8..49048213 100644 --- a/src/components/documentManager.ts +++ b/src/components/documentManager.ts @@ -227,8 +227,7 @@ export abstract class DocumentManager { const response = await getUserLibraryApi( JellyfinApi.jellyfinApi ).getItem({ - itemId, - userId: JellyfinApi.userId + itemId }); DocumentManager.showItem(response.data); diff --git a/src/components/jellyfinActions.ts b/src/components/jellyfinActions.ts index 8910ab1d..85f20bb4 100644 --- a/src/components/jellyfinActions.ts +++ b/src/components/jellyfinActions.ts @@ -247,8 +247,7 @@ export async function getPlaybackInfo( const query: PlaybackInfoDto = { DeviceProfile: deviceProfile, MaxStreamingBitrate: maxBitrate, - StartTimeTicks: startPosition || 0, - UserId: JellyfinApi.userId + StartTimeTicks: startPosition || 0 }; if (audioStreamIndex != null) { @@ -310,8 +309,7 @@ export async function getLiveStream( OpenToken: mediaSource.OpenToken, PlaySessionId: playSessionId, StartTimeTicks: startPosition || 0, - SubtitleStreamIndex: subtitleStreamIndex, - UserId: JellyfinApi.userId + SubtitleStreamIndex: subtitleStreamIndex } }); From 87767ea064d7a9c6dfc5b5c93f5c718b7e0cbcde Mon Sep 17 00:00:00 2001 From: Matthew Haughton <3flex@users.noreply.github.com> Date: Sun, 10 Nov 2024 23:20:30 +1100 Subject: [PATCH 2/2] Remove userId property from JellyfinApi --- src/components/__tests__/jellyfinApi.test.ts | 12 ++---------- src/components/jellyfinApi.ts | 7 +------ src/components/maincontroller.ts | 8 +------- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/components/__tests__/jellyfinApi.test.ts b/src/components/__tests__/jellyfinApi.test.ts index c0eb2287..4b2a8b92 100644 --- a/src/components/__tests__/jellyfinApi.test.ts +++ b/src/components/__tests__/jellyfinApi.test.ts @@ -21,11 +21,7 @@ describe('creating basic urls', () => { }); beforeEach(() => { - JellyfinApi.setServerInfo( - 'thisIsUserId', - 'thisIsAccessToken', - 'thisIsServerAddress' - ); + JellyfinApi.setServerInfo('thisIsAccessToken', 'thisIsServerAddress'); }); test('should return correct url', () => { @@ -58,11 +54,7 @@ describe('creating image urls', () => { }); beforeEach(() => { - JellyfinApi.setServerInfo( - 'thisIsUserId', - 'thisIsAccessToken', - 'thisIsServerAddress' - ); + JellyfinApi.setServerInfo('thisIsAccessToken', 'thisIsServerAddress'); }); test('should return correct url with all parameters provided', () => { diff --git a/src/components/jellyfinApi.ts b/src/components/jellyfinApi.ts index 859b02e4..524def06 100644 --- a/src/components/jellyfinApi.ts +++ b/src/components/jellyfinApi.ts @@ -25,9 +25,6 @@ axios.interceptors.response.use( // eslint-disable-next-line @typescript-eslint/no-extraneous-class export abstract class JellyfinApi { - // userId that we are connecting as currently - public static userId: string | undefined; - // Security token to prove authentication public static accessToken: string | undefined; @@ -47,7 +44,6 @@ export abstract class JellyfinApi { public static jellyfinApi: Api; public static setServerInfo( - userId?: string, accessToken?: string, serverAddress?: string, receiverName = '' @@ -57,9 +53,8 @@ export abstract class JellyfinApi { this.serverAddress !== serverAddress; console.debug( - `JellyfinApi.setServerInfo: user:${userId}, token:${accessToken}, server:${serverAddress}, name:${receiverName}` + `JellyfinApi.setServerInfo: token:${accessToken}, server:${serverAddress}, name:${receiverName}` ); - this.userId = userId; this.accessToken = accessToken; this.serverAddress = serverAddress; diff --git a/src/components/maincontroller.ts b/src/components/maincontroller.ts index 5454b5cc..c95df311 100644 --- a/src/components/maincontroller.ts +++ b/src/components/maincontroller.ts @@ -287,12 +287,7 @@ export async function reportDeviceCapabilities(): Promise { */ // eslint-disable-next-line @typescript-eslint/no-explicit-any export function processMessage(data: any): void { - if ( - !data.command || - !data.serverAddress || - !data.userId || - !data.accessToken - ) { + if (!data.command || !data.serverAddress || !data.accessToken) { console.log('Invalid message sent from sender. Sending error response'); broadcastToMessageBus({ @@ -309,7 +304,6 @@ export function processMessage(data: any): void { // Items will have properties - Id, Name, Type, MediaType, IsFolder JellyfinApi.setServerInfo( - data.userId, data.accessToken, data.serverAddress, data.receiverName