mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 15:32:37 -07:00
Fixed the approval issue for #939
This commit is contained in:
parent
ef0bc77771
commit
335e1b988a
1 changed files with 57 additions and 48 deletions
|
@ -1009,6 +1009,11 @@ namespace Ombi.UI.Modules
|
||||||
existingRequest.Episodes.AddRange(newEpisodes ?? Enumerable.Empty<EpisodesModel>());
|
existingRequest.Episodes.AddRange(newEpisodes ?? Enumerable.Empty<EpisodesModel>());
|
||||||
|
|
||||||
// It's technically a new request now, so set the status to not approved.
|
// It's technically a new request now, so set the status to not approved.
|
||||||
|
var autoApprove = ShouldAutoApprove(RequestType.TvShow);
|
||||||
|
if (autoApprove)
|
||||||
|
{
|
||||||
|
return await SendTv(model, sonarrSettings, existingRequest, fullShowName, settings);
|
||||||
|
}
|
||||||
existingRequest.Approved = false;
|
existingRequest.Approved = false;
|
||||||
|
|
||||||
return await AddUserToRequest(existingRequest, settings, fullShowName, true);
|
return await AddUserToRequest(existingRequest, settings, fullShowName, true);
|
||||||
|
@ -1135,54 +1140,7 @@ namespace Ombi.UI.Modules
|
||||||
{
|
{
|
||||||
if (ShouldAutoApprove(RequestType.TvShow))
|
if (ShouldAutoApprove(RequestType.TvShow))
|
||||||
{
|
{
|
||||||
model.Approved = true;
|
return await SendTv(model, sonarrSettings, existingRequest, fullShowName, settings);
|
||||||
var s = await sonarrSettings;
|
|
||||||
var sender = new TvSenderOld(SonarrApi, SickrageApi, Cache); // TODO put back
|
|
||||||
if (s.Enabled)
|
|
||||||
{
|
|
||||||
var result = await sender.SendToSonarr(s, model);
|
|
||||||
if (!string.IsNullOrEmpty(result?.title))
|
|
||||||
{
|
|
||||||
if (existingRequest != null)
|
|
||||||
{
|
|
||||||
return await UpdateRequest(model, settings,
|
|
||||||
$"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}");
|
|
||||||
}
|
|
||||||
return
|
|
||||||
await
|
|
||||||
AddRequest(model, settings,
|
|
||||||
$"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}");
|
|
||||||
}
|
|
||||||
Log.Debug("Error with sending to sonarr.");
|
|
||||||
return
|
|
||||||
Response.AsJson(ValidationHelper.SendSonarrError(result?.ErrorMessages ?? new List<string>()));
|
|
||||||
}
|
|
||||||
|
|
||||||
var srSettings = SickRageService.GetSettings();
|
|
||||||
if (srSettings.Enabled)
|
|
||||||
{
|
|
||||||
var result = sender.SendToSickRage(srSettings, model);
|
|
||||||
if (result?.result == "success")
|
|
||||||
{
|
|
||||||
return await AddRequest(model, settings,
|
|
||||||
$"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}");
|
|
||||||
}
|
|
||||||
return
|
|
||||||
Response.AsJson(new JsonResponseModel
|
|
||||||
{
|
|
||||||
Result = false,
|
|
||||||
Message = result?.message ?? Resources.UI.Search_SickrageError
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!srSettings.Enabled && !s.Enabled)
|
|
||||||
{
|
|
||||||
return await AddRequest(model, settings, $"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
Response.AsJson(new JsonResponseModel { Result = false, Message = Resources.UI.Search_TvNotSetUp });
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return await AddRequest(model, settings, $"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}");
|
return await AddRequest(model, settings, $"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}");
|
||||||
}
|
}
|
||||||
|
@ -1640,5 +1598,56 @@ namespace Ombi.UI.Modules
|
||||||
MostWatched,
|
MostWatched,
|
||||||
Trending
|
Trending
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<Response> SendTv(RequestedModel model, Task<SonarrSettings> sonarrSettings, RequestedModel existingRequest, string fullShowName, PlexRequestSettings settings)
|
||||||
|
{
|
||||||
|
model.Approved = true;
|
||||||
|
var s = await sonarrSettings;
|
||||||
|
var sender = new TvSenderOld(SonarrApi, SickrageApi, Cache); // TODO put back
|
||||||
|
if (s.Enabled)
|
||||||
|
{
|
||||||
|
var result = await sender.SendToSonarr(s, model);
|
||||||
|
if (!string.IsNullOrEmpty(result?.title))
|
||||||
|
{
|
||||||
|
if (existingRequest != null)
|
||||||
|
{
|
||||||
|
return await UpdateRequest(model, settings,
|
||||||
|
$"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}");
|
||||||
|
}
|
||||||
|
return
|
||||||
|
await
|
||||||
|
AddRequest(model, settings,
|
||||||
|
$"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}");
|
||||||
|
}
|
||||||
|
Log.Debug("Error with sending to sonarr.");
|
||||||
|
return
|
||||||
|
Response.AsJson(ValidationHelper.SendSonarrError(result?.ErrorMessages ?? new List<string>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
var srSettings = SickRageService.GetSettings();
|
||||||
|
if (srSettings.Enabled)
|
||||||
|
{
|
||||||
|
var result = sender.SendToSickRage(srSettings, model);
|
||||||
|
if (result?.result == "success")
|
||||||
|
{
|
||||||
|
return await AddRequest(model, settings,
|
||||||
|
$"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}");
|
||||||
|
}
|
||||||
|
return
|
||||||
|
Response.AsJson(new JsonResponseModel
|
||||||
|
{
|
||||||
|
Result = false,
|
||||||
|
Message = result?.message ?? Resources.UI.Search_SickrageError
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!srSettings.Enabled && !s.Enabled)
|
||||||
|
{
|
||||||
|
return await AddRequest(model, settings, $"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
Response.AsJson(new JsonResponseModel { Result = false, Message = Resources.UI.Search_TvNotSetUp });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue