diff --git a/Ombi.Api.Models/Sonarr/SonarrAddSeries.cs b/Ombi.Api.Models/Sonarr/SonarrAddSeries.cs index 881770e0c..4b0e24fe7 100644 --- a/Ombi.Api.Models/Sonarr/SonarrAddSeries.cs +++ b/Ombi.Api.Models/Sonarr/SonarrAddSeries.cs @@ -25,7 +25,7 @@ namespace Ombi.Api.Models.Sonarr { public SonarrAddSeries() { - images = new List(); + images = new List(); } public AddOptions addOptions { get; set; } public string title { get; set; } @@ -40,7 +40,7 @@ namespace Ombi.Api.Models.Sonarr public string imdbId { get; set; } public string titleSlug { get; set; } public int id { get; set; } - public List images { get; set; } + public List images { get; set; } [JsonIgnore] public List ErrorMessages { get; set; } } @@ -51,4 +51,18 @@ namespace Ombi.Api.Models.Sonarr public bool ignoreEpisodesWithoutFiles { get; set; } public bool searchForMissingEpisodes { get; set; } } + + public class Addoptions + { + public bool searchForMissingEpisodes { get; set; } + public bool ignoreEpisodesWithFiles { get; set; } + public bool ignoreEpisodesWithoutFiles { get; set; } + } + + public class SonarrImage + { + public string coverType { get; set; } + public string url { get; set; } + } + } diff --git a/Ombi.Api/ApiRequest.cs b/Ombi.Api/ApiRequest.cs index c399eae45..655bea670 100644 --- a/Ombi.Api/ApiRequest.cs +++ b/Ombi.Api/ApiRequest.cs @@ -45,7 +45,7 @@ namespace Ombi.Api MissingMemberHandling = MissingMemberHandling.Ignore }; - private static Logger Log = LogManager.GetCurrentClassLogger(); + private static readonly Logger Log = LogManager.GetCurrentClassLogger(); /// /// An API request handler /// @@ -58,8 +58,7 @@ namespace Ombi.Api var client = new RestClient { BaseUrl = baseUri }; var response = client.Execute(request); Log.Trace($"Request made to {response.ResponseUri} with status code {response.StatusCode}. The response was {response.Content}"); - - if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Created) + if ((int)response.StatusCode < 300) return response.Data; else throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}."); @@ -78,8 +77,7 @@ namespace Ombi.Api var client = new RestClient { BaseUrl = baseUri }; var response = client.Execute(request); Log.Trace($"Request made to {response.ResponseUri} with status code {response.StatusCode}. The response was {response.Content}"); - - if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Created) + if ((int)response.StatusCode < 300) return DeserializeXml(response.Content); else throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}."); @@ -92,7 +90,7 @@ namespace Ombi.Api var response = client.Execute(request); Log.Trace($"Request made to {response.ResponseUri} with status code {response.StatusCode}. The response was {response.Content}"); - if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Created) + if ((int)response.StatusCode < 300) return JsonConvert.DeserializeObject(response.Content, _settings); else throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}."); diff --git a/Ombi.UI/Modules/SearchModule.cs b/Ombi.UI/Modules/SearchModule.cs index c321f4724..185392a14 100644 --- a/Ombi.UI/Modules/SearchModule.cs +++ b/Ombi.UI/Modules/SearchModule.cs @@ -864,6 +864,14 @@ namespace Ombi.UI.Modules private async Task RequestMovie(int movieId) { + if(string.IsNullOrEmpty(Username)) + { + return Response.AsJson(new JsonResponseModel + { + Result = false, + Message = "Your session has expired, please refresh the page" + }); + } if (Security.HasPermissions(User, Permissions.ReadOnlyUser) || !Security.HasPermissions(User, Permissions.RequestMovie)) { return @@ -1031,6 +1039,14 @@ namespace Ombi.UI.Modules /// private async Task RequestTvShow(int showId, string seasons) { + if (string.IsNullOrEmpty(Username)) + { + return Response.AsJson(new JsonResponseModel + { + Result = false, + Message = "Your session has expired, please refresh the page" + }); + } if (Security.HasPermissions(User, Permissions.ReadOnlyUser) || !Security.HasPermissions(User, Permissions.RequestTvShow)) { return