mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 15:56:05 -07:00
Fixes for sonarr, we now display the error messages back to the user
This commit is contained in:
parent
3efd54c1b6
commit
10be8f0440
7 changed files with 55 additions and 16 deletions
|
@ -26,7 +26,7 @@ namespace PlexRequests.Api.Models.Sonarr
|
||||||
public string titleSlug { get; set; }
|
public string titleSlug { get; set; }
|
||||||
public int id { get; set; }
|
public int id { get; set; }
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string ErrorMessage { get; set; }
|
public List<string> ErrorMessages { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AddOptions
|
public class AddOptions
|
||||||
|
|
|
@ -24,13 +24,22 @@
|
||||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// ************************************************************************/
|
// ************************************************************************/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace PlexRequests.Api.Models.Sonarr
|
namespace PlexRequests.Api.Models.Sonarr
|
||||||
{
|
{
|
||||||
public class SonarrError
|
public class SonarrError
|
||||||
{
|
{
|
||||||
public string propertyName { get; set; }
|
public string propertyName { get; set; }
|
||||||
public string errorMessage { get; set; }
|
public string errorMessage { get; set; }
|
||||||
public string attemptedValue { get; set; }
|
public object attemptedValue { get; set; }
|
||||||
public string[] formattedMessageArguments { get; set; }
|
public FormattedMessagePlaceholderValues formattedMessagePlaceholderValues { get; set; }
|
||||||
|
}
|
||||||
|
public class FormattedMessagePlaceholderValues
|
||||||
|
{
|
||||||
|
public string propertyName { get; set; }
|
||||||
|
public object propertyValue { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -104,8 +104,8 @@ namespace PlexRequests.Api
|
||||||
catch (JsonSerializationException jse)
|
catch (JsonSerializationException jse)
|
||||||
{
|
{
|
||||||
Log.Error(jse);
|
Log.Error(jse);
|
||||||
var error = Api.ExecuteJson<SonarrError>(request, baseUrl);
|
var error = Api.ExecuteJson<List<SonarrError>>(request, baseUrl);
|
||||||
result = new SonarrAddSeries { ErrorMessage = error.errorMessage };
|
result = new SonarrAddSeries { ErrorMessages = error.Select(x => x.errorMessage).ToList() };
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -24,8 +24,10 @@
|
||||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// ************************************************************************/
|
// ************************************************************************/
|
||||||
#endregion
|
#endregion
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using Nancy.Validation;
|
using Nancy.Validation;
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,5 +57,31 @@ namespace PlexRequests.UI.Helpers
|
||||||
})
|
})
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static JsonResponseModel SendSonarrError(List<string> result)
|
||||||
|
{
|
||||||
|
var model = new JsonResponseModel {Result = false};
|
||||||
|
if (!result.Any())
|
||||||
|
{
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine("Errors from Sonarr: ");
|
||||||
|
for (var i = 0; i < result.Count; i++)
|
||||||
|
{
|
||||||
|
if (i != result.Count - 1)
|
||||||
|
{
|
||||||
|
sb.AppendLine(result[i] + ",");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.AppendLine(result[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
model.Message = sb.ToString();
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -100,7 +100,7 @@ namespace PlexRequests.UI.Modules
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var status = SonarrApi.SystemStatus(sonarrSettings.ApiKey, sonarrSettings.FullUri);
|
var status = SonarrApi.SystemStatus(sonarrSettings.ApiKey, sonarrSettings.FullUri);
|
||||||
return status != null
|
return status?.version != null
|
||||||
? Response.AsJson(new JsonResponseModel { Result = true, Message = "Connected to Sonarr successfully!" })
|
? Response.AsJson(new JsonResponseModel { Result = true, Message = "Connected to Sonarr successfully!" })
|
||||||
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Sonarr, please check your settings." });
|
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Sonarr, please check your settings." });
|
||||||
|
|
||||||
|
|
|
@ -135,14 +135,16 @@ namespace PlexRequests.UI.Modules
|
||||||
{
|
{
|
||||||
return Response.AsJson(new JsonResponseModel {Result = true});
|
return Response.AsJson(new JsonResponseModel {Result = true});
|
||||||
}
|
}
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Updated Sonarr but could not approve it in PlexRequests :(" });
|
return
|
||||||
}
|
Response.AsJson(new JsonResponseModel
|
||||||
return Response.AsJson(new JsonResponseModel
|
|
||||||
{
|
{
|
||||||
Result = false,
|
Result = false,
|
||||||
Message = result.ErrorMessage ?? "Could not add the series to Sonarr"
|
Message = "Updated Sonarr but could not approve it in PlexRequests :("
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
return Response.AsJson(ValidationHelper.SendSonarrError(result.ErrorMessages));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
var srSettings = SickRageSettings.GetSettings();
|
var srSettings = SickRageSettings.GetSettings();
|
||||||
if (srSettings.Enabled)
|
if (srSettings.Enabled)
|
||||||
|
@ -384,7 +386,7 @@ namespace PlexRequests.UI.Modules
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.Error("Could not approve and send the TV {0} to Sonarr!", r.Title);
|
Log.Error("Could not approve and send the TV {0} to Sonarr!", r.Title);
|
||||||
Log.Error("Error message: {0}", res?.ErrorMessage);
|
res?.ErrorMessages.ForEach(x => Log.Error("Error messages: {0}", x));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -442,7 +442,7 @@ namespace PlexRequests.UI.Modules
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = result?.ErrorMessage ?? "Something went wrong adding the movie to Sonarr! Please check your settings." });
|
return Response.AsJson(ValidationHelper.SendSonarrError(result?.ErrorMessages));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue