Fixed: Incorrect event types for interactive import required notifications
This commit is contained in:
parent
5ec282750b
commit
f56d504816
|
@ -70,7 +70,8 @@ namespace NzbDrone.Core.Download
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var historyItem = _historyService.MostRecentForDownloadId(trackedDownload.DownloadItem.DownloadId);
|
var grabbedHistories = _historyService.FindByDownloadId(trackedDownload.DownloadItem.DownloadId).Where(h => h.EventType == EpisodeHistoryEventType.Grabbed).ToList();
|
||||||
|
var historyItem = grabbedHistories.MaxBy(h => h.Date);
|
||||||
|
|
||||||
if (historyItem == null && trackedDownload.DownloadItem.Category.IsNullOrWhiteSpace())
|
if (historyItem == null && trackedDownload.DownloadItem.Category.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
|
@ -110,7 +111,9 @@ namespace NzbDrone.Core.Download
|
||||||
{
|
{
|
||||||
trackedDownload.HasNotifiedManualInteractionRequired = true;
|
trackedDownload.HasNotifiedManualInteractionRequired = true;
|
||||||
|
|
||||||
var manualInteractionEvent = new ManualInteractionRequiredEvent(trackedDownload);
|
var releaseInfo = new GrabbedReleaseInfo(grabbedHistories);
|
||||||
|
var manualInteractionEvent = new ManualInteractionRequiredEvent(trackedDownload, releaseInfo);
|
||||||
|
|
||||||
_eventAggregator.PublishEvent(manualInteractionEvent);
|
_eventAggregator.PublishEvent(manualInteractionEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,13 @@ namespace NzbDrone.Core.Download
|
||||||
{
|
{
|
||||||
public RemoteEpisode Episode { get; private set; }
|
public RemoteEpisode Episode { get; private set; }
|
||||||
public TrackedDownload TrackedDownload { get; private set; }
|
public TrackedDownload TrackedDownload { get; private set; }
|
||||||
|
public GrabbedReleaseInfo Release { get; private set; }
|
||||||
|
|
||||||
public ManualInteractionRequiredEvent(TrackedDownload trackedDownload)
|
public ManualInteractionRequiredEvent(TrackedDownload trackedDownload, GrabbedReleaseInfo release)
|
||||||
{
|
{
|
||||||
TrackedDownload = trackedDownload;
|
TrackedDownload = trackedDownload;
|
||||||
Episode = trackedDownload.RemoteEpisode;
|
Episode = trackedDownload.RemoteEpisode;
|
||||||
|
Release = release;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Linq;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.History;
|
using NzbDrone.Core.History;
|
||||||
|
@ -31,20 +32,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators
|
||||||
return localEpisode;
|
return localEpisode;
|
||||||
}
|
}
|
||||||
|
|
||||||
var episodeIds = grabbedHistories.Select(h => h.EpisodeId).Distinct().ToList();
|
localEpisode.Release = new GrabbedReleaseInfo(grabbedHistories);
|
||||||
var grabbedHistory = grabbedHistories.First();
|
|
||||||
var releaseInfo = new GrabbedReleaseInfo();
|
|
||||||
|
|
||||||
grabbedHistory.Data.TryGetValue("indexer", out var indexer);
|
|
||||||
grabbedHistory.Data.TryGetValue("size", out var sizeString);
|
|
||||||
long.TryParse(sizeString, out var size);
|
|
||||||
|
|
||||||
releaseInfo.Title = grabbedHistory.SourceTitle;
|
|
||||||
releaseInfo.Indexer = indexer;
|
|
||||||
releaseInfo.Size = size;
|
|
||||||
releaseInfo.EpisodeIds = episodeIds;
|
|
||||||
|
|
||||||
localEpisode.Release = releaseInfo;
|
|
||||||
|
|
||||||
return localEpisode;
|
return localEpisode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,7 +308,7 @@ namespace NzbDrone.Core.Notifications.CustomScript
|
||||||
var series = message.Series;
|
var series = message.Series;
|
||||||
var environmentVariables = new StringDictionary();
|
var environmentVariables = new StringDictionary();
|
||||||
|
|
||||||
environmentVariables.Add("Sonarr_EventType", "Download");
|
environmentVariables.Add("Sonarr_EventType", "ManualInteractionRequired");
|
||||||
environmentVariables.Add("Sonarr_InstanceName", _configFileProvider.InstanceName);
|
environmentVariables.Add("Sonarr_InstanceName", _configFileProvider.InstanceName);
|
||||||
environmentVariables.Add("Sonarr_ApplicationUrl", _configService.ApplicationUrl);
|
environmentVariables.Add("Sonarr_ApplicationUrl", _configService.ApplicationUrl);
|
||||||
environmentVariables.Add("Sonarr_Series_Id", series.Id.ToString());
|
environmentVariables.Add("Sonarr_Series_Id", series.Id.ToString());
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace NzbDrone.Core.Notifications
|
||||||
public string DownloadClientType { get; set; }
|
public string DownloadClientType { get; set; }
|
||||||
public string DownloadClientName { get; set; }
|
public string DownloadClientName { get; set; }
|
||||||
public string DownloadId { get; set; }
|
public string DownloadId { get; set; }
|
||||||
|
public GrabbedReleaseInfo Release { get; set; }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
|
|
@ -233,7 +233,8 @@ namespace NzbDrone.Core.Notifications
|
||||||
TrackedDownload = message.TrackedDownload,
|
TrackedDownload = message.TrackedDownload,
|
||||||
DownloadClientType = message.TrackedDownload.DownloadItem.DownloadClientInfo.Type,
|
DownloadClientType = message.TrackedDownload.DownloadItem.DownloadClientInfo.Type,
|
||||||
DownloadClientName = message.TrackedDownload.DownloadItem.DownloadClientInfo.Name,
|
DownloadClientName = message.TrackedDownload.DownloadItem.DownloadClientInfo.Name,
|
||||||
DownloadId = message.TrackedDownload.DownloadItem.DownloadId
|
DownloadId = message.TrackedDownload.DownloadItem.DownloadId,
|
||||||
|
Release = message.Release
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var notification in _notificationFactory.OnManualInteractionEnabled())
|
foreach (var notification in _notificationFactory.OnManualInteractionEnabled())
|
||||||
|
|
|
@ -165,13 +165,17 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
|
|
||||||
return new WebhookManualInteractionPayload
|
return new WebhookManualInteractionPayload
|
||||||
{
|
{
|
||||||
EventType = WebhookEventType.Grab,
|
EventType = WebhookEventType.ManualInteractionRequired,
|
||||||
|
InstanceName = _configFileProvider.InstanceName,
|
||||||
|
ApplicationUrl = _configService.ApplicationUrl,
|
||||||
Series = new WebhookSeries(message.Series),
|
Series = new WebhookSeries(message.Series),
|
||||||
Episodes = remoteEpisode.Episodes.ConvertAll(x => new WebhookEpisode(x)),
|
Episodes = remoteEpisode.Episodes.ConvertAll(x => new WebhookEpisode(x)),
|
||||||
DownloadInfo = new WebhookDownloadClientItem(quality, message.TrackedDownload.DownloadItem),
|
DownloadInfo = new WebhookDownloadClientItem(quality, message.TrackedDownload.DownloadItem),
|
||||||
DownloadClient = message.DownloadClientName,
|
DownloadClient = message.DownloadClientName,
|
||||||
DownloadClientType = message.DownloadClientType,
|
DownloadClientType = message.DownloadClientType,
|
||||||
DownloadId = message.DownloadId
|
DownloadId = message.DownloadId,
|
||||||
|
CustomFormatInfo = new WebhookCustomFormatInfo(remoteEpisode.CustomFormats, remoteEpisode.CustomFormatScore),
|
||||||
|
Release = new WebhookGrabbedRelease(message.Release)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
EpisodeFileDelete,
|
EpisodeFileDelete,
|
||||||
Health,
|
Health,
|
||||||
ApplicationUpdate,
|
ApplicationUpdate,
|
||||||
HealthRestored
|
HealthRestored,
|
||||||
|
ManualInteractionRequired
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,5 +10,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
public string DownloadClient { get; set; }
|
public string DownloadClient { get; set; }
|
||||||
public string DownloadClientType { get; set; }
|
public string DownloadClientType { get; set; }
|
||||||
public string DownloadId { get; set; }
|
public string DownloadId { get; set; }
|
||||||
|
public WebhookCustomFormatInfo CustomFormatInfo { get; set; }
|
||||||
|
public WebhookGrabbedRelease Release { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NzbDrone.Core.History;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Parser.Model
|
namespace NzbDrone.Core.Parser.Model
|
||||||
{
|
{
|
||||||
|
@ -9,5 +11,20 @@ namespace NzbDrone.Core.Parser.Model
|
||||||
public long Size { get; set; }
|
public long Size { get; set; }
|
||||||
|
|
||||||
public List<int> EpisodeIds { get; set; }
|
public List<int> EpisodeIds { get; set; }
|
||||||
|
|
||||||
|
public GrabbedReleaseInfo(List<EpisodeHistory> grabbedHistories)
|
||||||
|
{
|
||||||
|
var grabbedHistory = grabbedHistories.MaxBy(h => h.Date);
|
||||||
|
var episodeIds = grabbedHistories.Select(h => h.EpisodeId).Distinct().ToList();
|
||||||
|
|
||||||
|
grabbedHistory.Data.TryGetValue("indexer", out var indexer);
|
||||||
|
grabbedHistory.Data.TryGetValue("size", out var sizeString);
|
||||||
|
long.TryParse(sizeString, out var size);
|
||||||
|
|
||||||
|
Title = grabbedHistory.SourceTitle;
|
||||||
|
Indexer = indexer;
|
||||||
|
Size = size;
|
||||||
|
EpisodeIds = episodeIds;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue