From 0658b7943e1ab25816db9da34d4c9ea808d9203d Mon Sep 17 00:00:00 2001 From: sct Date: Mon, 14 Dec 2020 08:14:08 +0000 Subject: [PATCH] fix(services): radarr/sonarr will use the correct default server --- server/entity/MediaRequest.ts | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/server/entity/MediaRequest.ts b/server/entity/MediaRequest.ts index b00ddd9c8..dc20cad74 100644 --- a/server/entity/MediaRequest.ts +++ b/server/entity/MediaRequest.ts @@ -234,8 +234,19 @@ export class MediaRequest { return; } + const radarrSettings = settings.radarr.find( + (radarr) => radarr.isDefault && !radarr.is4k + ); + + if (!radarrSettings) { + logger.info( + 'There is no default radarr configured. Did you set any of your Radarr servers as default?', + { label: 'Media Request' } + ); + return; + } + const tmdb = new TheMovieDb(); - const radarrSettings = settings.radarr[0]; const radarr = new RadarrAPI({ apiKey: radarrSettings.apiKey, url: `${radarrSettings.useSsl ? 'https' : 'http'}://${ @@ -283,6 +294,18 @@ export class MediaRequest { return; } + const sonarrSettings = settings.sonarr.find( + (sonarr) => sonarr.isDefault && !sonarr.is4k + ); + + if (!sonarrSettings) { + logger.info( + 'There is no default sonarr configured. Did you set any of your Sonarr servers as default?', + { label: 'Media Request' } + ); + return; + } + const media = await mediaRepository.findOne({ where: { id: this.media.id }, relations: ['requests'], @@ -293,7 +316,6 @@ export class MediaRequest { } const tmdb = new TheMovieDb(); - const sonarrSettings = settings.sonarr[0]; const sonarr = new SonarrAPI({ apiKey: sonarrSettings.apiKey, url: `${sonarrSettings.useSsl ? 'https' : 'http'}://${