mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat(servarr): auto fill base url when testing service if missing (#1995)
* feat(servarr): auto fill base url when testing service if missing This will fill the base URL of the *arr service only if it's missing and the base URL hasn't been provided beforehand * fix(servarr): replace redundant check * fix(servarr): suggested changes
This commit is contained in:

committed by
GitHub

parent
54e9071e90
commit
739f667b54
@@ -2,6 +2,35 @@ import cacheManager, { AvailableCacheIds } from '../../lib/cache';
|
|||||||
import { DVRSettings } from '../../lib/settings';
|
import { DVRSettings } from '../../lib/settings';
|
||||||
import ExternalAPI from '../externalapi';
|
import ExternalAPI from '../externalapi';
|
||||||
|
|
||||||
|
export interface SystemStatus {
|
||||||
|
version: string;
|
||||||
|
buildTime: Date;
|
||||||
|
isDebug: boolean;
|
||||||
|
isProduction: boolean;
|
||||||
|
isAdmin: boolean;
|
||||||
|
isUserInteractive: boolean;
|
||||||
|
startupPath: string;
|
||||||
|
appData: string;
|
||||||
|
osName: string;
|
||||||
|
osVersion: string;
|
||||||
|
isNetCore: boolean;
|
||||||
|
isMono: boolean;
|
||||||
|
isLinux: boolean;
|
||||||
|
isOsx: boolean;
|
||||||
|
isWindows: boolean;
|
||||||
|
isDocker: boolean;
|
||||||
|
mode: string;
|
||||||
|
branch: string;
|
||||||
|
authentication: string;
|
||||||
|
sqliteVersion: string;
|
||||||
|
migrationVersion: number;
|
||||||
|
urlBase: string;
|
||||||
|
runtimeVersion: string;
|
||||||
|
runtimeName: string;
|
||||||
|
startTime: Date;
|
||||||
|
packageUpdateMechanism: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface RootFolder {
|
export interface RootFolder {
|
||||||
id: number;
|
id: number;
|
||||||
path: string;
|
path: string;
|
||||||
@@ -81,6 +110,18 @@ class ServarrBase<QueueItemAppendT> extends ExternalAPI {
|
|||||||
this.apiName = apiName;
|
this.apiName = apiName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getSystemStatus = async (): Promise<SystemStatus> => {
|
||||||
|
try {
|
||||||
|
const response = await this.axios.get<SystemStatus>('/system/status');
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(
|
||||||
|
`[${this.apiName}] Failed to retrieve system status: ${e.message}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public getProfiles = async (): Promise<QualityProfile[]> => {
|
public getProfiles = async (): Promise<QualityProfile[]> => {
|
||||||
try {
|
try {
|
||||||
const data = await this.getRolling<QualityProfile[]>(
|
const data = await this.getRolling<QualityProfile[]>(
|
||||||
|
@@ -46,6 +46,7 @@ radarrRoutes.post<
|
|||||||
url: RadarrAPI.buildUrl(req.body, '/api/v3'),
|
url: RadarrAPI.buildUrl(req.body, '/api/v3'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { urlBase } = await radarr.getSystemStatus();
|
||||||
const profiles = await radarr.getProfiles();
|
const profiles = await radarr.getProfiles();
|
||||||
const folders = await radarr.getRootFolders();
|
const folders = await radarr.getRootFolders();
|
||||||
const tags = await radarr.getTags();
|
const tags = await radarr.getTags();
|
||||||
@@ -57,6 +58,10 @@ radarrRoutes.post<
|
|||||||
path: folder.path,
|
path: folder.path,
|
||||||
})),
|
})),
|
||||||
tags,
|
tags,
|
||||||
|
urlBase:
|
||||||
|
req.body.baseUrl && req.body.baseUrl !== '/'
|
||||||
|
? req.body.baseUrl
|
||||||
|
: urlBase,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('Failed to test Radarr', {
|
logger.error('Failed to test Radarr', {
|
||||||
|
@@ -42,6 +42,7 @@ sonarrRoutes.post('/test', async (req, res, next) => {
|
|||||||
url: SonarrAPI.buildUrl(req.body, '/api/v3'),
|
url: SonarrAPI.buildUrl(req.body, '/api/v3'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { urlBase } = await sonarr.getSystemStatus();
|
||||||
const profiles = await sonarr.getProfiles();
|
const profiles = await sonarr.getProfiles();
|
||||||
const folders = await sonarr.getRootFolders();
|
const folders = await sonarr.getRootFolders();
|
||||||
const languageProfiles = await sonarr.getLanguageProfiles();
|
const languageProfiles = await sonarr.getLanguageProfiles();
|
||||||
@@ -55,6 +56,10 @@ sonarrRoutes.post('/test', async (req, res, next) => {
|
|||||||
})),
|
})),
|
||||||
languageProfiles,
|
languageProfiles,
|
||||||
tags,
|
tags,
|
||||||
|
urlBase:
|
||||||
|
req.body.baseUrl && req.body.baseUrl !== '/'
|
||||||
|
? req.body.baseUrl
|
||||||
|
: urlBase,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('Failed to test Sonarr', {
|
logger.error('Failed to test Sonarr', {
|
||||||
|
@@ -82,6 +82,7 @@ interface TestResponse {
|
|||||||
id: number;
|
id: number;
|
||||||
label: string;
|
label: string;
|
||||||
}[];
|
}[];
|
||||||
|
urlBase?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RadarrModalProps {
|
interface RadarrModalProps {
|
||||||
@@ -317,6 +318,9 @@ const RadarrModal: React.FC<RadarrModalProps> = ({
|
|||||||
port: values.port,
|
port: values.port,
|
||||||
useSsl: values.ssl,
|
useSsl: values.ssl,
|
||||||
});
|
});
|
||||||
|
if (!values.baseUrl || values.baseUrl === '/') {
|
||||||
|
setFieldValue('baseUrl', testResponse.urlBase);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
secondaryDisabled={
|
secondaryDisabled={
|
||||||
|
@@ -92,6 +92,7 @@ interface TestResponse {
|
|||||||
id: number;
|
id: number;
|
||||||
label: string;
|
label: string;
|
||||||
}[];
|
}[];
|
||||||
|
urlBase?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SonarrModalProps {
|
interface SonarrModalProps {
|
||||||
@@ -348,6 +349,9 @@ const SonarrModal: React.FC<SonarrModalProps> = ({
|
|||||||
port: values.port,
|
port: values.port,
|
||||||
useSsl: values.ssl,
|
useSsl: values.ssl,
|
||||||
});
|
});
|
||||||
|
if (!values.baseUrl || values.baseUrl === '/') {
|
||||||
|
setFieldValue('baseUrl', testResponse.urlBase);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
secondaryDisabled={
|
secondaryDisabled={
|
||||||
|
Reference in New Issue
Block a user