Skip to content

Commit

Permalink
fix(sonarr): 🐛 Added some more error handling and information around …
Browse files Browse the repository at this point in the history
…testing sonarr

#4877
  • Loading branch information
tidusjar committed Mar 28, 2023
1 parent 29dc84e commit bd2c2d3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
17 changes: 0 additions & 17 deletions src/Ombi.Api.Sonarr/Models/SystemStatus.cs
Expand Up @@ -3,23 +3,6 @@ namespace Ombi.Api.Sonarr
public class SystemStatus
{
public string version { get; set; }
public string buildTime { get; set; }
public bool isDebug { get; set; }
public bool isProduction { get; set; }
public bool isAdmin { get; set; }
public bool isUserInteractive { get; set; }
public string startupPath { get; set; }
public string appData { get; set; }
public string osVersion { get; set; }
public bool isMonoRuntime { get; set; }
public bool isMono { get; set; }
public bool isLinux { get; set; }
public bool isOsx { get; set; }
public bool isWindows { get; set; }
public string branch { get; set; }
public string authentication { get; set; }
public string sqliteVersion { get; set; }
public string urlBase { get; set; }
public string runtimeVersion { get; set; }
}
}
1 change: 1 addition & 0 deletions src/Ombi.Core/Models/TesterResultModel.cs
Expand Up @@ -5,5 +5,6 @@ public class TesterResultModel
public bool IsValid { get; set; }
public string Version { get; set; }
public string ExpectedSubDir { get; set; }
public string AdditionalInformation { get; set; }
}
}
1 change: 1 addition & 0 deletions src/Ombi/ClientApp/src/app/interfaces/ITester.ts
Expand Up @@ -2,4 +2,5 @@ export interface ITesterResult {
isValid: boolean;
version?: string;
expectedSubDir?: string;
additionalInformation?: string;
}
Expand Up @@ -220,7 +220,11 @@ export class SonarrComponent implements OnInit {
} else if (result.expectedSubDir) {
this.notificationService.error("Your Sonarr Base URL must be set to " + result.expectedSubDir);
} else {
this.notificationService.error("We could not connect to Sonarr!");
if (result.additionalInformation) {
this.notificationService.error(result.additionalInformation);
} else {
this.notificationService.error("We could not connect to Sonarr!");
}
}
});
}
Expand Down
24 changes: 24 additions & 0 deletions src/Ombi/Controllers/V1/External/TesterController.cs
Expand Up @@ -410,6 +410,30 @@ public async Task<TesterResultModel> Sonarr([FromBody] SonarrSettings settings)
{
try
{
if (string.IsNullOrEmpty(settings.ApiKey))
{
return new TesterResultModel
{
IsValid = false,
AdditionalInformation = "NullApiKey"
};
}
if (string.IsNullOrEmpty(settings.Ip))
{
return new TesterResultModel
{
IsValid = false,
AdditionalInformation = "NullIp"
};
}
if (settings.Port <= 0)
{
return new TesterResultModel
{
IsValid = false,
AdditionalInformation = "BadPort"
};
}

var result = await SonarrApi.SystemStatus(settings.ApiKey, settings.FullUri);
return new TesterResultModel
Expand Down

0 comments on commit bd2c2d3

Please sign in to comment.