1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-27 23:06:29 -04:00

New: On Episode File Delete For Upgrade notification option

This commit is contained in:
Robin Dadswell
2021-01-30 22:54:26 +00:00
committed by GitHub
parent ec058436d3
commit 474f4bcc6d
15 changed files with 77 additions and 4 deletions
@@ -116,6 +116,7 @@ namespace NzbDrone.Core.Test.NotificationTests
notification.SupportsOnRename.Should().BeTrue();
notification.SupportsOnSeriesDelete.Should().BeTrue();
notification.SupportsOnEpisodeFileDelete.Should().BeTrue();
notification.SupportsOnEpisodeFileDeleteForUpgrade.Should().BeTrue();
notification.SupportsOnHealthIssue.Should().BeTrue();
}
@@ -131,6 +132,7 @@ namespace NzbDrone.Core.Test.NotificationTests
notification.SupportsOnRename.Should().BeFalse();
notification.SupportsOnSeriesDelete.Should().BeFalse();
notification.SupportsOnEpisodeFileDelete.Should().BeFalse();
notification.SupportsOnEpisodeFileDeleteForUpgrade.Should().BeFalse();
notification.SupportsOnHealthIssue.Should().BeFalse();
}
}
@@ -0,0 +1,15 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(153)]
public class add_on_episodefiledelete_for_upgrade : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Alter.Table("Notifications").AddColumn("OnEpisodeFileDeleteForUpgrade").AsBoolean().WithDefaultValue(1);
}
}
}
@@ -76,6 +76,7 @@ namespace NzbDrone.Core.Datastore
.Ignore(i => i.SupportsOnRename)
.Ignore(i => i.SupportsOnSeriesDelete)
.Ignore(i => i.SupportsOnEpisodeFileDelete)
.Ignore(i => i.SupportsOnEpisodeFileDeleteForUpgrade)
.Ignore(i => i.SupportsOnHealthIssue);
Mapper.Entity<MetadataDefinition>().RegisterDefinition("Metadata")
@@ -135,6 +135,7 @@ namespace NzbDrone.Core.Notifications.CustomScript
var environmentVariables = new StringDictionary();
environmentVariables.Add("Sonarr_EventType", "EpisodeFileDelete");
environmentVariables.Add("Sonarr_EpisodeFile_DeleteReason", deleteMessage.Reason.ToString());
environmentVariables.Add("Sonarr_Series_Id", series.Id.ToString());
environmentVariables.Add("Sonarr_Series_Title", series.Title);
environmentVariables.Add("Sonarr_Series_Path", series.Path);
@@ -20,6 +20,7 @@ namespace NzbDrone.Core.Notifications
bool SupportsOnRename { get; }
bool SupportsOnSeriesDelete { get; }
bool SupportsOnEpisodeFileDelete { get; }
bool SupportsOnEpisodeFileDeleteForUpgrade { get; }
bool SupportsOnHealthIssue { get; }
}
}
@@ -75,6 +75,7 @@ namespace NzbDrone.Core.Notifications
public bool SupportsOnUpgrade => SupportsOnDownload;
public bool SupportsOnSeriesDelete => HasConcreteImplementation("OnSeriesDelete");
public bool SupportsOnEpisodeFileDelete => HasConcreteImplementation("OnEpisodeFileDelete");
public bool SupportsOnEpisodeFileDeleteForUpgrade => SupportsOnEpisodeFileDelete;
public bool SupportsOnHealthIssue => HasConcreteImplementation("OnHealthIssue");
protected TSettings Settings => (TSettings)Definition.Settings;
@@ -10,6 +10,7 @@ namespace NzbDrone.Core.Notifications
public bool OnRename { get; set; }
public bool OnSeriesDelete { get; set; }
public bool OnEpisodeFileDelete { get; set; }
public bool OnEpisodeFileDeleteForUpgrade { get; set; }
public bool OnHealthIssue { get; set; }
public bool SupportsOnGrab { get; set; }
public bool SupportsOnDownload { get; set; }
@@ -17,9 +18,10 @@ namespace NzbDrone.Core.Notifications
public bool SupportsOnRename { get; set; }
public bool SupportsOnSeriesDelete { get; set; }
public bool SupportsOnEpisodeFileDelete { get; set; }
public bool SupportsOnEpisodeFileDeleteForUpgrade { get; set; }
public bool SupportsOnHealthIssue { get; set; }
public bool IncludeHealthWarnings { get; set; }
public override bool Enable => OnGrab || OnDownload || (OnDownload && OnUpgrade) || OnSeriesDelete || OnEpisodeFileDelete || OnHealthIssue;
public override bool Enable => OnGrab || OnDownload || (OnDownload && OnUpgrade) || OnSeriesDelete || OnEpisodeFileDelete || OnEpisodeFileDeleteForUpgrade || OnHealthIssue;
}
}
@@ -15,6 +15,7 @@ namespace NzbDrone.Core.Notifications
List<INotification> OnRenameEnabled();
List<INotification> OnSeriesDeleteEnabled();
List<INotification> OnEpisodeFileDeleteEnabled();
List<INotification> OnEpisodeFileDeleteForUpgradeEnabled();
List<INotification> OnHealthIssueEnabled();
}
@@ -55,6 +56,10 @@ namespace NzbDrone.Core.Notifications
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnEpisodeFileDelete).ToList();
}
public List<INotification> OnEpisodeFileDeleteForUpgradeEnabled()
{
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnEpisodeFileDeleteForUpgrade).ToList();
}
public List<INotification> OnHealthIssueEnabled()
{
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnHealthIssue).ToList();
@@ -70,6 +75,7 @@ namespace NzbDrone.Core.Notifications
definition.SupportsOnRename = provider.SupportsOnRename;
definition.SupportsOnSeriesDelete = provider.SupportsOnSeriesDelete;
definition.SupportsOnEpisodeFileDelete = provider.SupportsOnEpisodeFileDelete;
definition.SupportsOnEpisodeFileDeleteForUpgrade = provider.SupportsOnEpisodeFileDeleteForUpgrade;
definition.SupportsOnHealthIssue = provider.SupportsOnHealthIssue;
}
}
@@ -205,9 +205,12 @@ namespace NzbDrone.Core.Notifications
{
try
{
if (ShouldHandleSeries(notification.Definition, deleteMessage.EpisodeFile.Series))
if (message.Reason != MediaFiles.DeleteMediaFileReason.Upgrade || ((NotificationDefinition)notification.Definition).OnEpisodeFileDeleteForUpgrade)
{
notification.OnEpisodeFileDelete(deleteMessage);
if (ShouldHandleSeries(notification.Definition, deleteMessage.EpisodeFile.Series))
{
notification.OnEpisodeFileDelete(deleteMessage);
}
}
}
catch (Exception ex)
@@ -82,7 +82,8 @@ namespace NzbDrone.Core.Notifications.Webhook
{
EventType = WebhookEventType.EpisodeFileDelete,
Series = new WebhookSeries(deleteMessage.Series),
Episodes = deleteMessage.EpisodeFile.Episodes.Value.ConvertAll(x => new WebhookEpisode(x))
Episodes = deleteMessage.EpisodeFile.Episodes.Value.ConvertAll(x => new WebhookEpisode(x)),
DeleteReason = deleteMessage.Reason
};
_proxy.SendWebhook(payload, Settings);
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using NzbDrone.Core.MediaFiles;
namespace NzbDrone.Core.Notifications.Webhook
{
@@ -6,6 +7,7 @@ namespace NzbDrone.Core.Notifications.Webhook
{
public WebhookSeries Series { get; set; }
public List<WebhookEpisode> Episodes { get; set; }
public DeleteMediaFileReason DeleteReason { get; set; }
}
}
@@ -11,6 +11,7 @@ namespace Sonarr.Api.V3.Notifications
public bool OnRename { get; set; }
public bool OnSeriesDelete { get; set; }
public bool OnEpisodeFileDelete { get; set; }
public bool OnEpisodeFileDeleteForUpgrade { get; set; }
public bool OnHealthIssue { get; set; }
public bool SupportsOnGrab { get; set; }
public bool SupportsOnDownload { get; set; }
@@ -18,6 +19,7 @@ namespace Sonarr.Api.V3.Notifications
public bool SupportsOnRename { get; set; }
public bool SupportsOnSeriesDelete { get; set; }
public bool SupportsOnEpisodeFileDelete { get; set; }
public bool SupportsOnEpisodeFileDeleteForUpgrade { get; set; }
public bool SupportsOnHealthIssue { get; set; }
public bool IncludeHealthWarnings { get; set; }
public string TestCommand { get; set; }
@@ -37,6 +39,7 @@ namespace Sonarr.Api.V3.Notifications
resource.OnRename = definition.OnRename;
resource.OnSeriesDelete = definition.OnSeriesDelete;
resource.OnEpisodeFileDelete = definition.OnEpisodeFileDelete;
resource.OnEpisodeFileDeleteForUpgrade = definition.OnEpisodeFileDeleteForUpgrade;
resource.OnHealthIssue = definition.OnHealthIssue;
resource.SupportsOnGrab = definition.SupportsOnGrab;
resource.SupportsOnDownload = definition.SupportsOnDownload;
@@ -44,6 +47,7 @@ namespace Sonarr.Api.V3.Notifications
resource.SupportsOnRename = definition.SupportsOnRename;
resource.SupportsOnSeriesDelete = definition.SupportsOnSeriesDelete;
resource.SupportsOnEpisodeFileDelete = definition.SupportsOnEpisodeFileDelete;
resource.SupportsOnEpisodeFileDeleteForUpgrade = definition.SupportsOnEpisodeFileDeleteForUpgrade;
resource.SupportsOnHealthIssue = definition.SupportsOnHealthIssue;
resource.IncludeHealthWarnings = definition.IncludeHealthWarnings;
@@ -62,6 +66,7 @@ namespace Sonarr.Api.V3.Notifications
definition.OnRename = resource.OnRename;
definition.OnSeriesDelete = resource.OnSeriesDelete;
definition.OnEpisodeFileDelete = resource.OnEpisodeFileDelete;
definition.OnEpisodeFileDeleteForUpgrade = resource.OnEpisodeFileDeleteForUpgrade;
definition.OnHealthIssue = resource.OnHealthIssue;
definition.SupportsOnGrab = resource.SupportsOnGrab;
definition.SupportsOnDownload = resource.SupportsOnDownload;
@@ -69,6 +74,7 @@ namespace Sonarr.Api.V3.Notifications
definition.SupportsOnRename = resource.SupportsOnRename;
definition.SupportsOnSeriesDelete = resource.SupportsOnSeriesDelete;
definition.SupportsOnEpisodeFileDelete = resource.SupportsOnEpisodeFileDelete;
definition.SupportsOnEpisodeFileDeleteForUpgrade = resource.SupportsOnEpisodeFileDeleteForUpgrade;
definition.SupportsOnHealthIssue = resource.SupportsOnHealthIssue;
definition.IncludeHealthWarnings = resource.IncludeHealthWarnings;