Fixed: Ensure grab notifications are sent according to tags requirements

pull/1822/head
Bogdan 10 months ago
parent f7727855b5
commit dfb00d9bb1

@ -74,6 +74,7 @@ namespace NzbDrone.Core.Download
DownloadClientId = downloadClient.Definition.Id,
DownloadClientName = downloadClient.Definition.Name,
Redirect = redirect,
Indexer = indexer,
GrabTrigger = source == "Prowlarr" ? GrabTrigger.Manual : GrabTrigger.Api
};
@ -152,6 +153,7 @@ namespace NzbDrone.Core.Download
var grabEvent = new IndexerDownloadEvent(release, success, source, host, release.Title, release.DownloadUrl)
{
Indexer = indexer,
GrabTrigger = source == "Prowlarr" ? GrabTrigger.Manual : GrabTrigger.Api
};
@ -204,6 +206,7 @@ namespace NzbDrone.Core.Download
var grabEvent = new IndexerDownloadEvent(release, true, source, host, release.Title, release.DownloadUrl)
{
Redirect = true,
Indexer = indexer,
GrabTrigger = source == "Prowlarr" ? GrabTrigger.Manual : GrabTrigger.Api
};

@ -16,6 +16,7 @@ namespace NzbDrone.Core.Indexers.Events
public string DownloadClient { get; set; }
public string DownloadClientName { get; set; }
public string DownloadId { get; set; }
public IIndexer Indexer { get; set; }
public GrabTrigger GrabTrigger { get; set; }
public IndexerDownloadEvent(ReleaseInfo release, bool successful, string source, string host, string title, string url)

@ -1,10 +1,13 @@
using System;
using System.Linq;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.HealthCheck;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Events;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Update.History.Events;
namespace NzbDrone.Core.Notifications
@ -185,7 +188,8 @@ namespace NzbDrone.Core.Notifications
{
try
{
if (ShouldHandleOnGrab(grabMessage, ((NotificationDefinition)notification.Definition).IncludeManualGrabs))
if (ShouldHandleIndexer(notification.Definition, (IndexerDefinition)message.Indexer.Definition) &&
ShouldHandleOnGrab(grabMessage, ((NotificationDefinition)notification.Definition).IncludeManualGrabs))
{
notification.OnGrab(grabMessage);
}
@ -196,5 +200,26 @@ namespace NzbDrone.Core.Notifications
}
}
}
private bool ShouldHandleIndexer(ProviderDefinition definition, ProviderDefinition indexer)
{
if (definition.Tags.Empty())
{
_logger.Debug("No tags set for this notification.");
return true;
}
if (definition.Tags.Intersect(indexer.Tags).Any())
{
_logger.Debug("Notification and indexer have one or more intersecting tags.");
return true;
}
_logger.Debug("{0} does not have any intersecting tags with {1}. Notification will not be sent.", definition.Name, indexer.Name);
return false;
}
}
}

Loading…
Cancel
Save