mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
Provide the base URL if possible for Sonarr/Radarr.
If the API returns a base URL that differs from the one currently set, output that in the error message. Even though Sonarr/Radarr return a result here, they will fail for POST requests, so this does need to be set correctly.
This commit is contained in:
parent
8e72a37fac
commit
a58a2a418e
9 changed files with 63 additions and 36 deletions
|
@ -3,5 +3,6 @@
|
||||||
public class SystemStatus
|
public class SystemStatus
|
||||||
{
|
{
|
||||||
public string version { get; set; }
|
public string version { get; set; }
|
||||||
|
public string urlBase { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
8
src/Ombi.Core/Models/TesterResultModel.cs
Normal file
8
src/Ombi.Core/Models/TesterResultModel.cs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
namespace Ombi.Core.Models
|
||||||
|
{
|
||||||
|
public class TesterResultModel
|
||||||
|
{
|
||||||
|
public bool IsValid { get; set; }
|
||||||
|
public string ExpectedSubDir { get; set; }
|
||||||
|
}
|
||||||
|
}
|
4
src/Ombi/ClientApp/src/app/interfaces/ITester.ts
Normal file
4
src/Ombi/ClientApp/src/app/interfaces/ITester.ts
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export interface ITesterResult {
|
||||||
|
isValid: boolean;
|
||||||
|
expectedSubDir?: string;
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
export * from "./ICommon";
|
export * from "./ICommon";
|
||||||
export * from "./ICouchPotato";
|
export * from "./ICouchPotato";
|
||||||
export * from "./IImages";
|
export * from "./IImages";
|
||||||
export * from "./IMediaServerStatus";
|
export * from "./IMediaServerStatus";
|
||||||
|
@ -20,3 +20,4 @@ export * from "./ISearchMusicResult";
|
||||||
export * from "./IVote";
|
export * from "./IVote";
|
||||||
export * from "./IFailedRequests";
|
export * from "./IFailedRequests";
|
||||||
export * from "./IHub";
|
export * from "./IHub";
|
||||||
|
export * from "./ITester";
|
||||||
|
|
|
@ -25,6 +25,7 @@ import {
|
||||||
ISlackNotificationSettings,
|
ISlackNotificationSettings,
|
||||||
ISonarrSettings,
|
ISonarrSettings,
|
||||||
ITelegramNotifcationSettings,
|
ITelegramNotifcationSettings,
|
||||||
|
ITesterResult,
|
||||||
IWebhookNotificationSettings,
|
IWebhookNotificationSettings,
|
||||||
IWhatsAppSettings,
|
IWhatsAppSettings,
|
||||||
} from "../../interfaces";
|
} from "../../interfaces";
|
||||||
|
@ -83,16 +84,16 @@ export class TesterService extends ServiceHelpers {
|
||||||
return this.http.post<boolean>(`${this.url}jellyfin`, JSON.stringify(settings), {headers: this.headers});
|
return this.http.post<boolean>(`${this.url}jellyfin`, JSON.stringify(settings), {headers: this.headers});
|
||||||
}
|
}
|
||||||
|
|
||||||
public radarrTest(settings: IRadarrSettings): Observable<boolean> {
|
public radarrTest(settings: IRadarrSettings): Observable<ITesterResult> {
|
||||||
return this.http.post<boolean>(`${this.url}radarr`, JSON.stringify(settings), {headers: this.headers});
|
return this.http.post<ITesterResult>(`${this.url}radarr`, JSON.stringify(settings), {headers: this.headers});
|
||||||
}
|
}
|
||||||
|
|
||||||
public lidarrTest(settings: ILidarrSettings): Observable<boolean> {
|
public lidarrTest(settings: ILidarrSettings): Observable<ITesterResult> {
|
||||||
return this.http.post<boolean>(`${this.url}lidarr`, JSON.stringify(settings), {headers: this.headers});
|
return this.http.post<ITesterResult>(`${this.url}lidarr`, JSON.stringify(settings), {headers: this.headers});
|
||||||
}
|
}
|
||||||
|
|
||||||
public sonarrTest(settings: ISonarrSettings): Observable<boolean> {
|
public sonarrTest(settings: ISonarrSettings): Observable<ITesterResult> {
|
||||||
return this.http.post<boolean>(`${this.url}sonarr`, JSON.stringify(settings), {headers: this.headers});
|
return this.http.post<ITesterResult>(`${this.url}sonarr`, JSON.stringify(settings), {headers: this.headers});
|
||||||
}
|
}
|
||||||
|
|
||||||
public couchPotatoTest(settings: ICouchPotatoSettings): Observable<boolean> {
|
public couchPotatoTest(settings: ICouchPotatoSettings): Observable<boolean> {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
||||||
|
|
||||||
import { ILidarrSettings, IMinimumAvailability, IProfiles, IRadarrProfile, IRadarrRootFolder } from "../../interfaces";
|
import { ILidarrSettings, IMinimumAvailability, IProfiles, IRadarrProfile, IRadarrRootFolder } from "../../interfaces";
|
||||||
|
@ -106,11 +106,13 @@ export class LidarrComponent implements OnInit {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const settings = <ILidarrSettings>form.value;
|
const settings = <ILidarrSettings>form.value;
|
||||||
this.testerService.lidarrTest(settings).subscribe(x => {
|
this.testerService.lidarrTest(settings).subscribe(result => {
|
||||||
if (x === true) {
|
if (result.isValid) {
|
||||||
this.notificationService.success("Successfully connected to Lidarr!");
|
this.notificationService.success("Successfully connected to Sonarr!");
|
||||||
|
} else if (result.expectedSubDir !== null) {
|
||||||
|
this.notificationService.error("Your Sonarr Base URL must be set to " + result.expectedSubDir);
|
||||||
} else {
|
} else {
|
||||||
this.notificationService.error("We could not connect to Lidarr!");
|
this.notificationService.error("We could not connect to Sonarr!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
||||||
|
|
||||||
import { IMinimumAvailability, IRadarrProfile, IRadarrRootFolder } from "../../interfaces";
|
import { IMinimumAvailability, IRadarrProfile, IRadarrRootFolder } from "../../interfaces";
|
||||||
|
@ -96,11 +96,13 @@ export class RadarrComponent implements OnInit {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const settings = <IRadarrSettings> form.value;
|
const settings = <IRadarrSettings> form.value;
|
||||||
this.testerService.radarrTest(settings).subscribe(x => {
|
this.testerService.radarrTest(settings).subscribe(result => {
|
||||||
if (x === true) {
|
if (result.isValid) {
|
||||||
this.notificationService.success("Successfully connected to Radarr!");
|
this.notificationService.success("Successfully connected to Sonarr!");
|
||||||
|
} else if (result.expectedSubDir !== null) {
|
||||||
|
this.notificationService.error("Your Sonarr Base URL must be set to " + result.expectedSubDir);
|
||||||
} else {
|
} else {
|
||||||
this.notificationService.error("We could not connect to Radarr!");
|
this.notificationService.error("We could not connect to Sonarr!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { FormBuilder, FormControl, FormGroup, Validators } from "@angular/forms";
|
import { FormBuilder, FormControl, FormGroup, Validators } from "@angular/forms";
|
||||||
|
|
||||||
import { ILanguageProfiles, ISonarrProfile, ISonarrRootFolder } from "../../interfaces";
|
import { ILanguageProfiles, ISonarrProfile, ISonarrRootFolder } from "../../interfaces";
|
||||||
|
@ -150,9 +150,11 @@ export class SonarrComponent implements OnInit {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const settings = <ISonarrSettings> form.value;
|
const settings = <ISonarrSettings> form.value;
|
||||||
this.testerService.sonarrTest(settings).subscribe(x => {
|
this.testerService.sonarrTest(settings).subscribe(result => {
|
||||||
if (x) {
|
if (result.isValid) {
|
||||||
this.notificationService.success("Successfully connected to Sonarr!");
|
this.notificationService.success("Successfully connected to Sonarr!");
|
||||||
|
} else if (result.expectedSubDir !== null) {
|
||||||
|
this.notificationService.error("Your Sonarr Base URL must be set to " + result.expectedSubDir);
|
||||||
} else {
|
} else {
|
||||||
this.notificationService.error("We could not connect to Sonarr!");
|
this.notificationService.error("We could not connect to Sonarr!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ using Ombi.Api.Sonarr;
|
||||||
using Ombi.Api.Twilio;
|
using Ombi.Api.Twilio;
|
||||||
using Ombi.Attributes;
|
using Ombi.Attributes;
|
||||||
using Ombi.Core.Authentication;
|
using Ombi.Core.Authentication;
|
||||||
|
using Ombi.Core.Models;
|
||||||
using Ombi.Core.Models.UI;
|
using Ombi.Core.Models.UI;
|
||||||
using Ombi.Core.Notifications;
|
using Ombi.Core.Notifications;
|
||||||
using Ombi.Core.Settings.Models.External;
|
using Ombi.Core.Settings.Models.External;
|
||||||
|
@ -364,19 +365,23 @@ namespace Ombi.Controllers.V1.External
|
||||||
/// <param name="settings"></param>
|
/// <param name="settings"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("radarr")]
|
[HttpPost("radarr")]
|
||||||
public async Task<bool> Radarr([FromBody] RadarrSettings settings)
|
public async Task<TesterResultModel> Radarr([FromBody] RadarrSettings settings)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var result = await RadarrApi.SystemStatus(settings.ApiKey, settings.FullUri);
|
var result = await RadarrApi.SystemStatus(settings.ApiKey, settings.FullUri);
|
||||||
return result.version != null;
|
return new TesterResultModel
|
||||||
|
{
|
||||||
|
IsValid = result.urlBase == settings.SubDir,
|
||||||
|
ExpectedSubDir = result.urlBase
|
||||||
|
};
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.LogError(LoggingEvents.Api, e, "Could not test Radarr");
|
Log.LogError(LoggingEvents.Api, e, "Could not test Radarr");
|
||||||
return false;
|
return new TesterResultModel { IsValid = false };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,23 +391,27 @@ namespace Ombi.Controllers.V1.External
|
||||||
/// <param name="settings"></param>
|
/// <param name="settings"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("sonarr")]
|
[HttpPost("sonarr")]
|
||||||
public async Task<bool> Sonarr([FromBody] SonarrSettings settings)
|
public async Task<TesterResultModel> Sonarr([FromBody] SonarrSettings settings)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
var result = await SonarrApi.SystemStatus(settings.ApiKey, settings.FullUri);
|
var result = await SonarrApi.SystemStatus(settings.ApiKey, settings.FullUri);
|
||||||
return result.version != null;
|
return new TesterResultModel
|
||||||
|
{
|
||||||
|
IsValid = result.urlBase == settings.SubDir,
|
||||||
|
ExpectedSubDir = result.urlBase
|
||||||
|
};
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.LogError(LoggingEvents.Api, e, "Could not test Sonarr");
|
Log.LogError(LoggingEvents.Api, e, "Could not test Sonarr");
|
||||||
return false;
|
return new TesterResultModel { IsValid = false };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if we can connect to Sonarr with the provided settings
|
/// Checks if we can connect to CouchPotato with the provided settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="settings"></param>
|
/// <param name="settings"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
@ -497,24 +506,21 @@ namespace Ombi.Controllers.V1.External
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("lidarr")]
|
[HttpPost("lidarr")]
|
||||||
public async Task<bool> LidarrTest([FromBody] LidarrSettings settings)
|
public async Task<TesterResultModel> LidarrTest([FromBody] LidarrSettings settings)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var status = await LidarrApi.Status(settings.ApiKey, settings.FullUri);
|
var status = await LidarrApi.Status(settings.ApiKey, settings.FullUri);
|
||||||
if (status != null & status?.version.HasValue() ?? false)
|
return new TesterResultModel
|
||||||
{
|
{
|
||||||
return true;
|
IsValid = status?.urlBase == settings.SubDir,
|
||||||
}
|
ExpectedSubDir = status?.urlBase
|
||||||
else
|
};
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.LogError(LoggingEvents.Api, e, "Could not test Lidarr");
|
Log.LogError(LoggingEvents.Api, e, "Could not test Lidarr");
|
||||||
return false;
|
return new TesterResultModel { IsValid = false };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue