Skip to content

Commit

Permalink
fix(build): remove circular dependency
Browse files Browse the repository at this point in the history
move emby header to jellyfin class instead externalapi class
  • Loading branch information
TOomaAh committed Jan 15, 2025
1 parent 353d079 commit 973e8d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 1 addition & 7 deletions server/api/externalapi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { MediaServerType } from '@server/constants/server';
import { getSettings } from '@server/lib/settings';
import type { RateLimitOptions } from '@server/utils/rateLimit';
import rateLimit from '@server/utils/rateLimit';
import type NodeCache from 'node-cache';
Expand Down Expand Up @@ -36,8 +34,6 @@ class ExternalAPI {

const url = new URL(baseUrl);

const settings = getSettings();

this.defaultHeaders = {
'Content-Type': 'application/json',
Accept: 'application/json',
Expand All @@ -46,9 +42,7 @@ class ExternalAPI {
`${url.username}:${url.password}`
).toString('base64')}`,
}),
...(settings.main.mediaServerType === MediaServerType.EMBY && {
'Accept-Encoding': 'gzip',
}),

...options.headers,
};

Expand Down
7 changes: 7 additions & 0 deletions server/api/jellyfin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import ExternalAPI from '@server/api/externalapi';
import { ApiErrorCode } from '@server/constants/error';
import { MediaServerType } from '@server/constants/server';
import availabilitySync from '@server/lib/availabilitySync';
import { getSettings } from '@server/lib/settings';
import logger from '@server/logger';
import { ApiError } from '@server/types/error';
import { getAppVersion } from '@server/utils/appVersion';
Expand Down Expand Up @@ -103,12 +105,17 @@ class JellyfinAPI extends ExternalAPI {
authHeaderVal = `MediaBrowser Client="Jellyseerr", Device="Jellyseerr", DeviceId="${deviceId}", Version="${getAppVersion()}"`;
}

const settings = getSettings();

super(
jellyfinHost,
{},
{
headers: {
'X-Emby-Authorization': authHeaderVal,
...(settings.main.mediaServerType === MediaServerType.EMBY && {
'Accept-Encoding': 'gzip',
}),
},
}
);
Expand Down

0 comments on commit 973e8d1

Please sign in to comment.