mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
New: On Episode File Delete For Upgrade notification option
This commit is contained in:
parent
ec058436d3
commit
474f4bcc6d
@ -44,6 +44,7 @@ function EditNotificationModalContent(props) {
|
||||
onRename,
|
||||
onSeriesDelete,
|
||||
onEpisodeFileDelete,
|
||||
onEpisodeFileDeleteForUpgrade,
|
||||
onHealthIssue,
|
||||
supportsOnGrab,
|
||||
supportsOnDownload,
|
||||
@ -51,6 +52,7 @@ function EditNotificationModalContent(props) {
|
||||
supportsOnRename,
|
||||
supportsOnSeriesDelete,
|
||||
supportsOnEpisodeFileDelete,
|
||||
supportsOnEpisodeFileDeleteForUpgrade,
|
||||
supportsOnHealthIssue,
|
||||
includeHealthWarnings,
|
||||
tags,
|
||||
@ -180,6 +182,23 @@ function EditNotificationModalContent(props) {
|
||||
/>
|
||||
</FormGroup>
|
||||
|
||||
{
|
||||
onEpisodeFileDelete.value ?
|
||||
<FormGroup>
|
||||
<FormLabel>On Episode File Delete For Upgrade</FormLabel>
|
||||
|
||||
<FormInputGroup
|
||||
type={inputTypes.CHECK}
|
||||
name="onEpisodeFileDeleteForUpgrade"
|
||||
helpText="Be notified when episode files are deleted for upgrades"
|
||||
isDisabled={!supportsOnEpisodeFileDeleteForUpgrade.value}
|
||||
{...onEpisodeFileDeleteForUpgrade}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</FormGroup> :
|
||||
null
|
||||
}
|
||||
|
||||
<FormGroup>
|
||||
<FormLabel>On Health Issue</FormLabel>
|
||||
|
||||
|
@ -60,6 +60,7 @@ class Notification extends Component {
|
||||
onRename,
|
||||
onSeriesDelete,
|
||||
onEpisodeFileDelete,
|
||||
onEpisodeFileDeleteForUpgrade,
|
||||
onHealthIssue,
|
||||
supportsOnGrab,
|
||||
supportsOnDownload,
|
||||
@ -67,6 +68,7 @@ class Notification extends Component {
|
||||
supportsOnRename,
|
||||
supportsOnSeriesDelete,
|
||||
supportsOnEpisodeFileDelete,
|
||||
supportsOnEpisodeFileDeleteForUpgrade,
|
||||
supportsOnHealthIssue
|
||||
} = this.props;
|
||||
|
||||
@ -136,6 +138,14 @@ class Notification extends Component {
|
||||
null
|
||||
}
|
||||
|
||||
{
|
||||
supportsOnEpisodeFileDeleteForUpgrade && onEpisodeFileDelete && onEpisodeFileDeleteForUpgrade ?
|
||||
<Label kind={kinds.SUCCESS}>
|
||||
On Episode File Delete For Upgrade
|
||||
</Label> :
|
||||
null
|
||||
}
|
||||
|
||||
{
|
||||
!onGrab && !onDownload && !onRename && !onHealthIssue && !onSeriesDelete && !onEpisodeFileDelete ?
|
||||
<Label
|
||||
@ -177,11 +187,13 @@ Notification.propTypes = {
|
||||
onRename: PropTypes.bool.isRequired,
|
||||
onSeriesDelete: PropTypes.bool.isRequired,
|
||||
onEpisodeFileDelete: PropTypes.bool.isRequired,
|
||||
onEpisodeFileDeleteForUpgrade: PropTypes.bool.isRequired,
|
||||
onHealthIssue: PropTypes.bool.isRequired,
|
||||
supportsOnGrab: PropTypes.bool.isRequired,
|
||||
supportsOnDownload: PropTypes.bool.isRequired,
|
||||
supportsOnSeriesDelete: PropTypes.bool.isRequired,
|
||||
supportsOnEpisodeFileDelete: PropTypes.bool.isRequired,
|
||||
supportsOnEpisodeFileDeleteForUpgrade: PropTypes.bool.isRequired,
|
||||
supportsOnUpgrade: PropTypes.bool.isRequired,
|
||||
supportsOnRename: PropTypes.bool.isRequired,
|
||||
supportsOnHealthIssue: PropTypes.bool.isRequired,
|
||||
|
@ -108,6 +108,7 @@ export default {
|
||||
selectedSchema.onRename = selectedSchema.supportsOnRename;
|
||||
selectedSchema.OnSeriesDelete = selectedSchema.supportsOnSeriesDelete;
|
||||
selectedSchema.OnEpisodeFileDelete = selectedSchema.supportsOnEpisodeFileDelete;
|
||||
selectedSchema.OnEpisodeFileDeleteForUpgrade = selectedSchema.supportsOnEpisodeFileDeleteForUpgrade;
|
||||
|
||||
return selectedSchema;
|
||||
});
|
||||
|
@ -116,6 +116,7 @@ public void should_support_all_if_implemented()
|
||||
notification.SupportsOnRename.Should().BeTrue();
|
||||
notification.SupportsOnSeriesDelete.Should().BeTrue();
|
||||
notification.SupportsOnEpisodeFileDelete.Should().BeTrue();
|
||||
notification.SupportsOnEpisodeFileDeleteForUpgrade.Should().BeTrue();
|
||||
notification.SupportsOnHealthIssue.Should().BeTrue();
|
||||
}
|
||||
|
||||
@ -131,6 +132,7 @@ public void should_support_none_if_none_are_implemented()
|
||||
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 @@ public static void Map()
|
||||
.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 @@ public override void OnEpisodeFileDelete(EpisodeDeleteMessage deleteMessage)
|
||||
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 @@ public interface INotification : IProvider
|
||||
bool SupportsOnRename { get; }
|
||||
bool SupportsOnSeriesDelete { get; }
|
||||
bool SupportsOnEpisodeFileDelete { get; }
|
||||
bool SupportsOnEpisodeFileDeleteForUpgrade { get; }
|
||||
bool SupportsOnHealthIssue { get; }
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ public virtual void ProcessQueue()
|
||||
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 @@ public class NotificationDefinition : ProviderDefinition
|
||||
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 @@ public class NotificationDefinition : ProviderDefinition
|
||||
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 @@ public interface INotificationFactory : IProviderFactory<INotification, Notifica
|
||||
List<INotification> OnRenameEnabled();
|
||||
List<INotification> OnSeriesDeleteEnabled();
|
||||
List<INotification> OnEpisodeFileDeleteEnabled();
|
||||
List<INotification> OnEpisodeFileDeleteForUpgradeEnabled();
|
||||
List<INotification> OnHealthIssueEnabled();
|
||||
}
|
||||
|
||||
@ -55,6 +56,10 @@ public List<INotification> OnEpisodeFileDeleteEnabled()
|
||||
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 @@ public override void SetProviderCharacteristics(INotification provider, Notifica
|
||||
definition.SupportsOnRename = provider.SupportsOnRename;
|
||||
definition.SupportsOnSeriesDelete = provider.SupportsOnSeriesDelete;
|
||||
definition.SupportsOnEpisodeFileDelete = provider.SupportsOnEpisodeFileDelete;
|
||||
definition.SupportsOnEpisodeFileDeleteForUpgrade = provider.SupportsOnEpisodeFileDeleteForUpgrade;
|
||||
definition.SupportsOnHealthIssue = provider.SupportsOnHealthIssue;
|
||||
}
|
||||
}
|
||||
|
@ -205,9 +205,12 @@ public void Handle(EpisodeFileDeletedEvent message)
|
||||
{
|
||||
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 @@ public override void OnEpisodeFileDelete(EpisodeDeleteMessage deleteMessage)
|
||||
{
|
||||
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 @@ public class WebhookEpisodeDeletePayload : WebhookPayload
|
||||
{
|
||||
public WebhookSeries Series { get; set; }
|
||||
public List<WebhookEpisode> Episodes { get; set; }
|
||||
public DeleteMediaFileReason DeleteReason { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ public class NotificationResource : ProviderResource
|
||||
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 @@ public class NotificationResource : ProviderResource
|
||||
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 @@ public override NotificationResource ToResource(NotificationDefinition definitio
|
||||
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 @@ public override NotificationResource ToResource(NotificationDefinition definitio
|
||||
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 @@ public override NotificationDefinition ToModel(NotificationResource resource)
|
||||
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 @@ public override NotificationDefinition ToModel(NotificationResource resource)
|
||||
definition.SupportsOnRename = resource.SupportsOnRename;
|
||||
definition.SupportsOnSeriesDelete = resource.SupportsOnSeriesDelete;
|
||||
definition.SupportsOnEpisodeFileDelete = resource.SupportsOnEpisodeFileDelete;
|
||||
definition.SupportsOnEpisodeFileDeleteForUpgrade = resource.SupportsOnEpisodeFileDeleteForUpgrade;
|
||||
definition.SupportsOnHealthIssue = resource.SupportsOnHealthIssue;
|
||||
definition.IncludeHealthWarnings = resource.IncludeHealthWarnings;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user