Skip to content

Commit

Permalink
Merge pull request #700 from 3flex/remove-userid
Browse files Browse the repository at this point in the history
Remove all usage of userId
  • Loading branch information
nielsvanvelzen authored Nov 10, 2024
2 parents 75d340e + 87767ea commit 745dc16
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 29 deletions.
12 changes: 2 additions & 10 deletions src/components/__tests__/jellyfinApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ describe('creating basic urls', () => {
});

beforeEach(() => {
JellyfinApi.setServerInfo(
'thisIsUserId',
'thisIsAccessToken',
'thisIsServerAddress'
);
JellyfinApi.setServerInfo('thisIsAccessToken', 'thisIsServerAddress');
});

test('should return correct url', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down
3 changes: 1 addition & 2 deletions src/components/documentManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ export abstract class DocumentManager {
const response = await getUserLibraryApi(
JellyfinApi.jellyfinApi
).getItem({
itemId,
userId: JellyfinApi.userId
itemId
});

DocumentManager.showItem(response.data);
Expand Down
6 changes: 2 additions & 4 deletions src/components/jellyfinActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -310,8 +309,7 @@ export async function getLiveStream(
OpenToken: mediaSource.OpenToken,
PlaySessionId: playSessionId,
StartTimeTicks: startPosition || 0,
SubtitleStreamIndex: subtitleStreamIndex,
UserId: JellyfinApi.userId
SubtitleStreamIndex: subtitleStreamIndex
}
});

Expand Down
7 changes: 1 addition & 6 deletions src/components/jellyfinApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -47,7 +44,6 @@ export abstract class JellyfinApi {
public static jellyfinApi: Api;

public static setServerInfo(
userId?: string,
accessToken?: string,
serverAddress?: string,
receiverName = ''
Expand All @@ -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;

Expand Down
8 changes: 1 addition & 7 deletions src/components/maincontroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,7 @@ export async function reportDeviceCapabilities(): Promise<void> {
*/
// 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({
Expand All @@ -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
Expand Down

0 comments on commit 745dc16

Please sign in to comment.