Fixed a sonarr deseralization error.

pull/1284/head
tidusjar 8 years ago
parent 2b27559277
commit 20c4ce8b7d

@ -25,7 +25,7 @@ namespace Ombi.Api.Models.Sonarr
{ {
public SonarrAddSeries() public SonarrAddSeries()
{ {
images = new List<string>(); images = new List<SonarrImage>();
} }
public AddOptions addOptions { get; set; } public AddOptions addOptions { get; set; }
public string title { get; set; } public string title { get; set; }
@ -40,7 +40,7 @@ namespace Ombi.Api.Models.Sonarr
public string imdbId { get; set; } public string imdbId { get; set; }
public string titleSlug { get; set; } public string titleSlug { get; set; }
public int id { get; set; } public int id { get; set; }
public List<string> images { get; set; } public List<SonarrImage> images { get; set; }
[JsonIgnore] [JsonIgnore]
public List<string> ErrorMessages { get; set; } public List<string> ErrorMessages { get; set; }
} }
@ -51,4 +51,18 @@ namespace Ombi.Api.Models.Sonarr
public bool ignoreEpisodesWithoutFiles { get; set; } public bool ignoreEpisodesWithoutFiles { get; set; }
public bool searchForMissingEpisodes { 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; }
}
} }

@ -45,7 +45,7 @@ namespace Ombi.Api
MissingMemberHandling = MissingMemberHandling.Ignore MissingMemberHandling = MissingMemberHandling.Ignore
}; };
private static Logger Log = LogManager.GetCurrentClassLogger(); private static readonly Logger Log = LogManager.GetCurrentClassLogger();
/// <summary> /// <summary>
/// An API request handler /// An API request handler
/// </summary> /// </summary>
@ -58,8 +58,7 @@ namespace Ombi.Api
var client = new RestClient { BaseUrl = baseUri }; var client = new RestClient { BaseUrl = baseUri };
var response = client.Execute<T>(request); var response = client.Execute<T>(request);
Log.Trace($"Request made to {response.ResponseUri} with status code {response.StatusCode}. The response was {response.Content}"); Log.Trace($"Request made to {response.ResponseUri} with status code {response.StatusCode}. The response was {response.Content}");
if ((int)response.StatusCode < 300)
if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Created)
return response.Data; return response.Data;
else else
throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}."); throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}.");
@ -78,8 +77,7 @@ namespace Ombi.Api
var client = new RestClient { BaseUrl = baseUri }; var client = new RestClient { BaseUrl = baseUri };
var response = client.Execute(request); var response = client.Execute(request);
Log.Trace($"Request made to {response.ResponseUri} with status code {response.StatusCode}. The response was {response.Content}"); Log.Trace($"Request made to {response.ResponseUri} with status code {response.StatusCode}. The response was {response.Content}");
if ((int)response.StatusCode < 300)
if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Created)
return DeserializeXml<T>(response.Content); return DeserializeXml<T>(response.Content);
else else
throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}."); throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}.");
@ -92,7 +90,7 @@ namespace Ombi.Api
var response = client.Execute(request); var response = client.Execute(request);
Log.Trace($"Request made to {response.ResponseUri} with status code {response.StatusCode}. The response was {response.Content}"); 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<T>(response.Content, _settings); return JsonConvert.DeserializeObject<T>(response.Content, _settings);
else else
throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}."); throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}.");

@ -864,6 +864,14 @@ namespace Ombi.UI.Modules
private async Task<Response> RequestMovie(int movieId) private async Task<Response> 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)) if (Security.HasPermissions(User, Permissions.ReadOnlyUser) || !Security.HasPermissions(User, Permissions.RequestMovie))
{ {
return return
@ -1031,6 +1039,14 @@ namespace Ombi.UI.Modules
/// <returns></returns> /// <returns></returns>
private async Task<Response> RequestTvShow(int showId, string seasons) private async Task<Response> 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)) if (Security.HasPermissions(User, Permissions.ReadOnlyUser) || !Security.HasPermissions(User, Permissions.RequestTvShow))
{ {
return return

Loading…
Cancel
Save