New: Notifiarr and Webhook Updates

Closes #3062
pull/3295/head
Qstick 2 years ago
parent 2038e8e85d
commit d999a4d582

@ -1,7 +1,9 @@
using System; using System;
using System.Collections.Generic;
using FluentAssertions; using FluentAssertions;
using FluentValidation.Results; using FluentValidation.Results;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
using NzbDrone.Core.Notifications; using NzbDrone.Core.Notifications;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
@ -57,7 +59,7 @@ namespace NzbDrone.Core.Test.NotificationTests
TestLogger.Info("OnAlbumDownload was called"); TestLogger.Info("OnAlbumDownload was called");
} }
public override void OnRename(Artist artist) public override void OnRename(Artist artist, List<RenamedTrackFile> renamedFiles)
{ {
TestLogger.Info("OnRename was called"); TestLogger.Info("OnRename was called");
} }

@ -65,7 +65,7 @@ namespace NzbDrone.Core.Test.NotificationTests
{ {
(Subject.Definition.Settings as SynologyIndexerSettings).UpdateLibrary = false; (Subject.Definition.Settings as SynologyIndexerSettings).UpdateLibrary = false;
Subject.OnRename(_artist); Subject.OnRename(_artist, new List<RenamedTrackFile>());
Mocker.GetMock<ISynologyIndexerProxy>() Mocker.GetMock<ISynologyIndexerProxy>()
.Verify(v => v.UpdateFolder(_artist.Path), Times.Never()); .Verify(v => v.UpdateFolder(_artist.Path), Times.Never());
@ -95,7 +95,7 @@ namespace NzbDrone.Core.Test.NotificationTests
[Test] [Test]
public void should_update_entire_series_folder_on_rename() public void should_update_entire_series_folder_on_rename()
{ {
Subject.OnRename(_artist); Subject.OnRename(_artist, new List<RenamedTrackFile>());
Mocker.GetMock<ISynologyIndexerProxy>() Mocker.GetMock<ISynologyIndexerProxy>()
.Verify(v => v.UpdateFolder(@"C:\Test\".AsOsAgnostic()), Times.Once()); .Verify(v => v.UpdateFolder(@"C:\Test\".AsOsAgnostic()), Times.Once());

@ -1,4 +1,5 @@
using NzbDrone.Common.Messaging; using System.Collections.Generic;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
namespace NzbDrone.Core.MediaFiles.Events namespace NzbDrone.Core.MediaFiles.Events
@ -6,10 +7,12 @@ namespace NzbDrone.Core.MediaFiles.Events
public class ArtistRenamedEvent : IEvent public class ArtistRenamedEvent : IEvent
{ {
public Artist Artist { get; private set; } public Artist Artist { get; private set; }
public List<RenamedTrackFile> RenamedFiles { get; private set; }
public ArtistRenamedEvent(Artist artist) public ArtistRenamedEvent(Artist artist, List<RenamedTrackFile> renamedFiles)
{ {
Artist = artist; Artist = artist;
RenamedFiles = renamedFiles;
} }
} }
} }

@ -112,11 +112,11 @@ namespace NzbDrone.Core.MediaFiles
private void RenameFiles(List<TrackFile> trackFiles, Artist artist) private void RenameFiles(List<TrackFile> trackFiles, Artist artist)
{ {
var renamed = new List<TrackFile>(); var renamed = new List<RenamedTrackFile>();
foreach (var trackFile in trackFiles) foreach (var trackFile in trackFiles)
{ {
var trackFilePath = trackFile.Path; var previousPath = trackFile.Path;
try try
{ {
@ -124,11 +124,16 @@ namespace NzbDrone.Core.MediaFiles
_trackFileMover.MoveTrackFile(trackFile, artist); _trackFileMover.MoveTrackFile(trackFile, artist);
_mediaFileService.Update(trackFile); _mediaFileService.Update(trackFile);
renamed.Add(trackFile);
renamed.Add(new RenamedTrackFile
{
TrackFile = trackFile,
PreviousPath = previousPath
});
_logger.Debug("Renamed track file: {0}", trackFile); _logger.Debug("Renamed track file: {0}", trackFile);
_eventAggregator.PublishEvent(new TrackFileRenamedEvent(artist, trackFile, trackFilePath)); _eventAggregator.PublishEvent(new TrackFileRenamedEvent(artist, trackFile, previousPath));
} }
catch (SameFilenameException ex) catch (SameFilenameException ex)
{ {
@ -136,13 +141,13 @@ namespace NzbDrone.Core.MediaFiles
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.Error(ex, "Failed to rename file {0}", trackFilePath); _logger.Error(ex, "Failed to rename file {0}", previousPath);
} }
} }
if (renamed.Any()) if (renamed.Any())
{ {
_eventAggregator.PublishEvent(new ArtistRenamedEvent(artist)); _eventAggregator.PublishEvent(new ArtistRenamedEvent(artist, renamed));
_logger.Debug("Removing Empty Subfolders from: {0}", artist.Path); _logger.Debug("Removing Empty Subfolders from: {0}", artist.Path);
_diskProvider.RemoveEmptySubfolders(artist.Path); _diskProvider.RemoveEmptySubfolders(artist.Path);

@ -0,0 +1,8 @@
namespace NzbDrone.Core.MediaFiles
{
public class RenamedTrackFile
{
public TrackFile TrackFile { get; set; }
public string PreviousPath { get; set; }
}
}

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Core.Download;
using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
@ -12,7 +13,7 @@ namespace NzbDrone.Core.Notifications
public AlbumRelease Release { get; set; } public AlbumRelease Release { get; set; }
public List<TrackFile> TrackFiles { get; set; } public List<TrackFile> TrackFiles { get; set; }
public List<TrackFile> OldFiles { get; set; } public List<TrackFile> OldFiles { get; set; }
public string DownloadClient { get; set; } public DownloadClientItemClientInfo DownloadClientInfo { get; set; }
public string DownloadId { get; set; } public string DownloadId { get; set; }
public override string ToString() public override string ToString()

@ -9,6 +9,7 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Common.Processes; using NzbDrone.Common.Processes;
using NzbDrone.Common.Serializer; using NzbDrone.Common.Serializer;
using NzbDrone.Core.HealthCheck; using NzbDrone.Core.HealthCheck;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation; using NzbDrone.Core.Validation;
@ -56,7 +57,8 @@ namespace NzbDrone.Core.Notifications.CustomScript
environmentVariables.Add("Lidarr_Release_Quality", remoteAlbum.ParsedAlbumInfo.Quality.Quality.Name); environmentVariables.Add("Lidarr_Release_Quality", remoteAlbum.ParsedAlbumInfo.Quality.Quality.Name);
environmentVariables.Add("Lidarr_Release_QualityVersion", remoteAlbum.ParsedAlbumInfo.Quality.Revision.Version.ToString()); environmentVariables.Add("Lidarr_Release_QualityVersion", remoteAlbum.ParsedAlbumInfo.Quality.Revision.Version.ToString());
environmentVariables.Add("Lidarr_Release_ReleaseGroup", releaseGroup ?? string.Empty); environmentVariables.Add("Lidarr_Release_ReleaseGroup", releaseGroup ?? string.Empty);
environmentVariables.Add("Lidarr_Download_Client", message.DownloadClient ?? string.Empty); environmentVariables.Add("Lidarr_Download_Client", message.DownloadClientName ?? string.Empty);
environmentVariables.Add("Lidarr_Download_Client_Type", message.DownloadClientType ?? string.Empty);
environmentVariables.Add("Lidarr_Download_Id", message.DownloadId ?? string.Empty); environmentVariables.Add("Lidarr_Download_Id", message.DownloadId ?? string.Empty);
ExecuteScript(environmentVariables); ExecuteScript(environmentVariables);
@ -80,7 +82,8 @@ namespace NzbDrone.Core.Notifications.CustomScript
environmentVariables.Add("Lidarr_Album_MBId", album.ForeignAlbumId); environmentVariables.Add("Lidarr_Album_MBId", album.ForeignAlbumId);
environmentVariables.Add("Lidarr_AlbumRelease_MBId", release.ForeignReleaseId); environmentVariables.Add("Lidarr_AlbumRelease_MBId", release.ForeignReleaseId);
environmentVariables.Add("Lidarr_Album_ReleaseDate", album.ReleaseDate.ToString()); environmentVariables.Add("Lidarr_Album_ReleaseDate", album.ReleaseDate.ToString());
environmentVariables.Add("Lidarr_Download_Client", message.DownloadClient ?? string.Empty); environmentVariables.Add("Lidarr_Download_Client", message.DownloadClientInfo?.Name ?? string.Empty);
environmentVariables.Add("Lidarr_Download_Client_Type", message.DownloadClientInfo?.Type ?? string.Empty);
environmentVariables.Add("Lidarr_Download_Id", message.DownloadId ?? string.Empty); environmentVariables.Add("Lidarr_Download_Id", message.DownloadId ?? string.Empty);
if (message.TrackFiles.Any()) if (message.TrackFiles.Any())
@ -96,7 +99,7 @@ namespace NzbDrone.Core.Notifications.CustomScript
ExecuteScript(environmentVariables); ExecuteScript(environmentVariables);
} }
public override void OnRename(Artist artist) public override void OnRename(Artist artist, List<RenamedTrackFile> renamedFiles)
{ {
var environmentVariables = new StringDictionary(); var environmentVariables = new StringDictionary();
@ -106,6 +109,9 @@ namespace NzbDrone.Core.Notifications.CustomScript
environmentVariables.Add("Lidarr_Artist_Path", artist.Path); environmentVariables.Add("Lidarr_Artist_Path", artist.Path);
environmentVariables.Add("Lidarr_Artist_MBId", artist.Metadata.Value.ForeignArtistId); environmentVariables.Add("Lidarr_Artist_MBId", artist.Metadata.Value.ForeignArtistId);
environmentVariables.Add("Lidarr_Artist_Type", artist.Metadata.Value.Type); environmentVariables.Add("Lidarr_Artist_Type", artist.Metadata.Value.Type);
environmentVariables.Add("Lidarr_TrackFile_Ids", string.Join(",", renamedFiles.Select(e => e.TrackFile.Id)));
environmentVariables.Add("Lidarr_TrackFile_Paths", string.Join("|", renamedFiles.Select(e => e.TrackFile.Path)));
environmentVariables.Add("Lidarr_TrackFile_PreviousPaths", string.Join("|", renamedFiles.Select(e => e.PreviousPath)));
ExecuteScript(environmentVariables); ExecuteScript(environmentVariables);
} }

@ -4,6 +4,7 @@ using System.Linq;
using FluentValidation.Results; using FluentValidation.Results;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
using NzbDrone.Core.Notifications.Discord.Payloads; using NzbDrone.Core.Notifications.Discord.Payloads;
using NzbDrone.Core.Validation; using NzbDrone.Core.Validation;
@ -206,7 +207,7 @@ namespace NzbDrone.Core.Notifications.Discord
_proxy.SendPayload(payload, Settings); _proxy.SendPayload(payload, Settings);
} }
public override void OnRename(Artist artist) public override void OnRename(Artist artist, List<RenamedTrackFile> renamedFiles)
{ {
var attachments = new List<Embed> var attachments = new List<Embed>
{ {

@ -10,7 +10,8 @@ namespace NzbDrone.Core.Notifications
public Artist Artist { get; set; } public Artist Artist { get; set; }
public RemoteAlbum Album { get; set; } public RemoteAlbum Album { get; set; }
public QualityModel Quality { get; set; } public QualityModel Quality { get; set; }
public string DownloadClient { get; set; } public string DownloadClientType { get; set; }
public string DownloadClientName { get; set; }
public string DownloadId { get; set; } public string DownloadId { get; set; }
public override string ToString() public override string ToString()

@ -1,3 +1,5 @@
using System.Collections.Generic;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
@ -9,7 +11,7 @@ namespace NzbDrone.Core.Notifications
void OnGrab(GrabMessage grabMessage); void OnGrab(GrabMessage grabMessage);
void OnReleaseImport(AlbumDownloadMessage message); void OnReleaseImport(AlbumDownloadMessage message);
void OnRename(Artist artist); void OnRename(Artist artist, List<RenamedTrackFile> renamedFiles);
void OnAlbumDelete(AlbumDeleteMessage deleteMessage); void OnAlbumDelete(AlbumDeleteMessage deleteMessage);
void OnArtistDelete(ArtistDeleteMessage deleteMessage); void OnArtistDelete(ArtistDeleteMessage deleteMessage);
void OnHealthIssue(HealthCheck.HealthCheck healthCheck); void OnHealthIssue(HealthCheck.HealthCheck healthCheck);

@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using FluentValidation.Results; using FluentValidation.Results;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
namespace NzbDrone.Core.Notifications.Emby namespace NzbDrone.Core.Notifications.Emby
@ -38,7 +39,7 @@ namespace NzbDrone.Core.Notifications.Emby
} }
} }
public override void OnRename(Artist artist) public override void OnRename(Artist artist, List<RenamedTrackFile> renamedFiles)
{ {
if (Settings.UpdateLibrary) if (Settings.UpdateLibrary)
{ {

@ -1,19 +1,20 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using FluentValidation.Results; using FluentValidation.Results;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.HealthCheck; using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music;
using NzbDrone.Core.Notifications.Webhook;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Notifications.Notifiarr namespace NzbDrone.Core.Notifications.Notifiarr
{ {
public class Notifiarr : NotificationBase<NotifiarrSettings> public class Notifiarr : WebhookBase<NotifiarrSettings>
{ {
private readonly INotifiarrProxy _proxy; private readonly INotifiarrProxy _proxy;
public Notifiarr(INotifiarrProxy proxy) public Notifiarr(INotifiarrProxy proxy, IConfigFileProvider configFileProvider)
: base(configFileProvider)
{ {
_proxy = proxy; _proxy = proxy;
} }
@ -23,98 +24,75 @@ namespace NzbDrone.Core.Notifications.Notifiarr
public override void OnGrab(GrabMessage message) public override void OnGrab(GrabMessage message)
{ {
var artist = message.Artist; _proxy.SendNotification(BuildOnGrabPayload(message), Settings);
var remoteAlbum = message.Album;
var releaseGroup = remoteAlbum.ParsedAlbumInfo.ReleaseGroup;
var variables = new StringDictionary();
variables.Add("Lidarr_EventType", "Grab");
variables.Add("Lidarr_Artist_Id", artist.Id.ToString());
variables.Add("Lidarr_Artist_Name", artist.Metadata.Value.Name);
variables.Add("Lidarr_Artist_MBId", artist.Metadata.Value.ForeignArtistId);
variables.Add("Lidarr_Artist_Type", artist.Metadata.Value.Type);
variables.Add("Lidarr_Release_AlbumCount", remoteAlbum.Albums.Count.ToString());
variables.Add("Lidarr_Release_AlbumReleaseDates", string.Join(",", remoteAlbum.Albums.Select(e => e.ReleaseDate)));
variables.Add("Lidarr_Release_AlbumTitles", string.Join("|", remoteAlbum.Albums.Select(e => e.Title)));
variables.Add("Lidarr_Release_AlbumMBIds", string.Join("|", remoteAlbum.Albums.Select(e => e.ForeignAlbumId)));
variables.Add("Lidarr_Release_Title", remoteAlbum.Release.Title);
variables.Add("Lidarr_Release_Indexer", remoteAlbum.Release.Indexer ?? string.Empty);
variables.Add("Lidarr_Release_Size", remoteAlbum.Release.Size.ToString());
variables.Add("Lidarr_Release_Quality", remoteAlbum.ParsedAlbumInfo.Quality.Quality.Name);
variables.Add("Lidarr_Release_QualityVersion", remoteAlbum.ParsedAlbumInfo.Quality.Revision.Version.ToString());
variables.Add("Lidarr_Release_ReleaseGroup", releaseGroup ?? string.Empty);
variables.Add("Lidarr_Download_Client", message.DownloadClient ?? string.Empty);
variables.Add("Lidarr_Download_Id", message.DownloadId ?? string.Empty);
_proxy.SendNotification(variables, Settings);
} }
public override void OnReleaseImport(AlbumDownloadMessage message) public override void OnReleaseImport(AlbumDownloadMessage message)
{ {
var artist = message.Artist; _proxy.SendNotification(BuildOnReleaseImportPayload(message), Settings);
var album = message.Album; }
var release = message.Release;
var variables = new StringDictionary();
variables.Add("Lidarr_EventType", "Download");
variables.Add("Lidarr_Artist_Id", artist.Id.ToString());
variables.Add("Lidarr_Artist_Name", artist.Metadata.Value.Name);
variables.Add("Lidarr_Artist_Path", artist.Path);
variables.Add("Lidarr_Artist_MBId", artist.Metadata.Value.ForeignArtistId);
variables.Add("Lidarr_Artist_Type", artist.Metadata.Value.Type);
variables.Add("Lidarr_Album_Id", album.Id.ToString());
variables.Add("Lidarr_Album_Title", album.Title);
variables.Add("Lidarr_Album_MBId", album.ForeignAlbumId);
variables.Add("Lidarr_AlbumRelease_MBId", release.ForeignReleaseId);
variables.Add("Lidarr_Album_ReleaseDate", album.ReleaseDate.ToString());
variables.Add("Lidarr_Download_Client", message.DownloadClient ?? string.Empty);
variables.Add("Lidarr_Download_Id", message.DownloadId ?? string.Empty);
if (message.TrackFiles.Any())
{
variables.Add("Lidarr_AddedTrackPaths", string.Join("|", message.TrackFiles.Select(e => e.Path)));
}
if (message.OldFiles.Any()) public override void OnDownloadFailure(DownloadFailedMessage message)
{ {
variables.Add("Lidarr_DeletedPaths", string.Join("|", message.OldFiles.Select(e => e.Path))); _proxy.SendNotification(BuildOnDownloadFailurePayload(message), Settings);
} }
_proxy.SendNotification(variables, Settings); public override void OnImportFailure(AlbumDownloadMessage message)
{
_proxy.SendNotification(BuildOnImportFailurePayload(message), Settings);
} }
public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck) public override void OnRename(Artist artist, List<RenamedTrackFile> renamedFiles)
{ {
var variables = new StringDictionary(); _proxy.SendNotification(BuildOnRenamePayload(artist, renamedFiles), Settings);
}
variables.Add("Lidarr_EventType", "HealthIssue"); public override void OnTrackRetag(TrackRetagMessage message)
variables.Add("Lidarr_Health_Issue_Level", Enum.GetName(typeof(HealthCheckResult), healthCheck.Type)); {
variables.Add("Lidarr_Health_Issue_Message", healthCheck.Message); _proxy.SendNotification(BuildOnTrackRetagPayload(message), Settings);
variables.Add("Lidarr_Health_Issue_Type", healthCheck.Source.Name); }
variables.Add("Lidarr_Health_Issue_Wiki", healthCheck.WikiUrl.ToString() ?? string.Empty);
_proxy.SendNotification(variables, Settings); public override void OnAlbumDelete(AlbumDeleteMessage deleteMessage)
{
_proxy.SendNotification(BuildOnAlbumDelete(deleteMessage), Settings);
} }
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) public override void OnArtistDelete(ArtistDeleteMessage deleteMessage)
{ {
var variables = new StringDictionary(); _proxy.SendNotification(BuildOnArtistDelete(deleteMessage), Settings);
}
variables.Add("Lidarr_EventType", "ApplicationUpdate"); public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
variables.Add("Lidarr_Update_Message", updateMessage.Message); {
variables.Add("Lidarr_Update_NewVersion", updateMessage.NewVersion.ToString()); _proxy.SendNotification(BuildHealthPayload(healthCheck), Settings);
variables.Add("Lidarr_Update_PreviousVersion", updateMessage.PreviousVersion.ToString()); }
_proxy.SendNotification(variables, Settings); public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
{
_proxy.SendNotification(BuildApplicationUpdatePayload(updateMessage), Settings);
} }
public override ValidationResult Test() public override ValidationResult Test()
{ {
var failures = new List<ValidationFailure>(); var failures = new List<ValidationFailure>();
failures.AddIfNotNull(_proxy.Test(Settings)); failures.AddIfNotNull(SendWebhookTest());
return new ValidationResult(failures); return new ValidationResult(failures);
} }
private ValidationFailure SendWebhookTest()
{
try
{
_proxy.SendNotification(BuildTestPayload(), Settings);
}
catch (NotifiarrException ex)
{
return new NzbDroneValidationFailure("APIKey", ex.Message);
}
return null;
}
} }
} }

@ -1,73 +1,43 @@
using System; using System.Net.Http;
using System.Collections.Specialized;
using FluentValidation.Results;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration; using NzbDrone.Common.Serializer;
using NzbDrone.Core.Notifications.Webhook;
namespace NzbDrone.Core.Notifications.Notifiarr namespace NzbDrone.Core.Notifications.Notifiarr
{ {
public interface INotifiarrProxy public interface INotifiarrProxy
{ {
void SendNotification(StringDictionary message, NotifiarrSettings settings); void SendNotification(WebhookPayload payload, NotifiarrSettings settings);
ValidationFailure Test(NotifiarrSettings settings);
} }
public class NotifiarrProxy : INotifiarrProxy public class NotifiarrProxy : INotifiarrProxy
{ {
private const string URL = "https://notifiarr.com"; private const string URL = "https://notifiarr.com";
private readonly IHttpClient _httpClient; private readonly IHttpClient _httpClient;
private readonly IConfigFileProvider _configFileProvider;
private readonly Logger _logger;
public NotifiarrProxy(IHttpClient httpClient, IConfigFileProvider configFileProvider, Logger logger) public NotifiarrProxy(IHttpClient httpClient)
{ {
_httpClient = httpClient; _httpClient = httpClient;
_configFileProvider = configFileProvider;
_logger = logger;
} }
public void SendNotification(StringDictionary message, NotifiarrSettings settings) public void SendNotification(WebhookPayload payload, NotifiarrSettings settings)
{ {
ProcessNotification(message, settings); ProcessNotification(payload, settings);
} }
public ValidationFailure Test(NotifiarrSettings settings) private void ProcessNotification(WebhookPayload payload, NotifiarrSettings settings)
{ {
try try
{ {
var variables = new StringDictionary(); var request = new HttpRequestBuilder(URL + "/api/v1/notification/lidarr")
variables.Add("Lidarr_EventType", "Test"); .Accept(HttpAccept.Json)
.SetHeader("X-API-Key", settings.APIKey)
.Build();
SendNotification(variables, settings); request.Method = HttpMethod.Post;
return null;
}
catch (NotifiarrException ex)
{
return new ValidationFailure("APIKey", ex.Message);
}
catch (Exception ex)
{
_logger.Error(ex, ex.Message);
return new ValidationFailure("", "Unable to send test notification. Check the log for more details.");
}
}
private void ProcessNotification(StringDictionary message, NotifiarrSettings settings)
{
try
{
var instanceName = _configFileProvider.InstanceName;
var requestBuilder = new HttpRequestBuilder(URL + "/api/v1/notification/lidarr/" + settings.APIKey).Post();
requestBuilder.AddFormParameter("instanceName", instanceName).Build();
foreach (string key in message.Keys)
{
requestBuilder.AddFormParameter(key, message[key]);
}
var request = requestBuilder.Build(); request.Headers.ContentType = "application/json";
request.SetContent(payload.ToJson());
_httpClient.Post(request); _httpClient.Post(request);
} }
@ -77,25 +47,20 @@ namespace NzbDrone.Core.Notifications.Notifiarr
switch ((int)responseCode) switch ((int)responseCode)
{ {
case 401: case 401:
_logger.Error("Unauthorized", "HTTP 401 - API key is invalid");
throw new NotifiarrException("API key is invalid"); throw new NotifiarrException("API key is invalid");
case 400: case 400:
_logger.Error("Invalid Request", "HTTP 400 - Unable to send notification. Ensure Lidarr Integration is enabled & assigned a channel on Notifiarr");
throw new NotifiarrException("Unable to send notification. Ensure Lidarr Integration is enabled & assigned a channel on Notifiarr"); throw new NotifiarrException("Unable to send notification. Ensure Lidarr Integration is enabled & assigned a channel on Notifiarr");
case 502: case 502:
case 503: case 503:
case 504: case 504:
_logger.Error("Service Unavailable", "Unable to send notification. Service Unavailable");
throw new NotifiarrException("Unable to send notification. Service Unavailable", ex); throw new NotifiarrException("Unable to send notification. Service Unavailable", ex);
case 520: case 520:
case 521: case 521:
case 522: case 522:
case 523: case 523:
case 524: case 524:
_logger.Error(ex, "Cloudflare Related HTTP Error - Unable to send notification");
throw new NotifiarrException("Cloudflare Related HTTP Error - Unable to send notification", ex); throw new NotifiarrException("Cloudflare Related HTTP Error - Unable to send notification", ex);
default: default:
_logger.Error(ex, "Unknown HTTP Error - Unable to send notification");
throw new NotifiarrException("Unknown HTTP Error - Unable to send notification", ex); throw new NotifiarrException("Unknown HTTP Error - Unable to send notification", ex);
} }
} }

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using FluentValidation.Results; using FluentValidation.Results;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
@ -50,7 +51,7 @@ namespace NzbDrone.Core.Notifications
{ {
} }
public virtual void OnRename(Artist artist) public virtual void OnRename(Artist artist, List<RenamedTrackFile> renamedFiles)
{ {
} }

@ -126,7 +126,8 @@ namespace NzbDrone.Core.Notifications
Artist = message.Album.Artist, Artist = message.Album.Artist,
Quality = message.Album.ParsedAlbumInfo.Quality, Quality = message.Album.ParsedAlbumInfo.Quality,
Album = message.Album, Album = message.Album,
DownloadClient = message.DownloadClient, DownloadClientName = message.DownloadClientName,
DownloadClientType = message.DownloadClient,
DownloadId = message.DownloadId DownloadId = message.DownloadId
}; };
@ -161,7 +162,7 @@ namespace NzbDrone.Core.Notifications
Artist = message.Artist, Artist = message.Artist,
Album = message.Album, Album = message.Album,
Release = message.AlbumRelease, Release = message.AlbumRelease,
DownloadClient = message.DownloadClientInfo?.Name, DownloadClientInfo = message.DownloadClientInfo,
DownloadId = message.DownloadId, DownloadId = message.DownloadId,
TrackFiles = message.ImportedTracks, TrackFiles = message.ImportedTracks,
OldFiles = message.OldFiles, OldFiles = message.OldFiles,
@ -194,7 +195,7 @@ namespace NzbDrone.Core.Notifications
{ {
if (ShouldHandleArtist(notification.Definition, message.Artist)) if (ShouldHandleArtist(notification.Definition, message.Artist))
{ {
notification.OnRename(message.Artist); notification.OnRename(message.Artist, message.RenamedFiles);
} }
} }
catch (Exception ex) catch (Exception ex)

@ -6,6 +6,7 @@ using NLog;
using NzbDrone.Common.Cache; using NzbDrone.Common.Cache;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.Exceptions; using NzbDrone.Core.Exceptions;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
using NzbDrone.Core.Notifications.Plex.PlexTv; using NzbDrone.Core.Notifications.Plex.PlexTv;
using NzbDrone.Core.Validation; using NzbDrone.Core.Validation;
@ -43,7 +44,7 @@ namespace NzbDrone.Core.Notifications.Plex.Server
UpdateIfEnabled(message.Artist); UpdateIfEnabled(message.Artist);
} }
public override void OnRename(Artist artist) public override void OnRename(Artist artist, List<RenamedTrackFile> renamedFiles)
{ {
UpdateIfEnabled(artist); UpdateIfEnabled(artist);
} }

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using FluentValidation.Results; using FluentValidation.Results;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
using NzbDrone.Core.Notifications.Slack.Payloads; using NzbDrone.Core.Notifications.Slack.Payloads;
using NzbDrone.Core.Validation; using NzbDrone.Core.Validation;
@ -54,7 +55,7 @@ namespace NzbDrone.Core.Notifications.Slack
_proxy.SendPayload(payload, Settings); _proxy.SendPayload(payload, Settings);
} }
public override void OnRename(Artist artist) public override void OnRename(Artist artist, List<RenamedTrackFile> renamedFiles)
{ {
var attachments = new List<Attachment> var attachments = new List<Attachment>
{ {

@ -3,6 +3,7 @@ using System.Net.Sockets;
using FluentValidation.Results; using FluentValidation.Results;
using NLog; using NLog;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
namespace NzbDrone.Core.Notifications.Subsonic namespace NzbDrone.Core.Notifications.Subsonic
@ -35,7 +36,7 @@ namespace NzbDrone.Core.Notifications.Subsonic
Update(); Update();
} }
public override void OnRename(Artist artist) public override void OnRename(Artist artist, List<RenamedTrackFile> renamedFiles)
{ {
Update(); Update();
} }

@ -2,6 +2,7 @@ using System.Collections.Generic;
using FluentValidation.Results; using FluentValidation.Results;
using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
namespace NzbDrone.Core.Notifications.Synology namespace NzbDrone.Core.Notifications.Synology
@ -38,7 +39,7 @@ namespace NzbDrone.Core.Notifications.Synology
} }
} }
public override void OnRename(Artist artist) public override void OnRename(Artist artist, List<RenamedTrackFile> renamedFiles)
{ {
if (Settings.UpdateLibrary) if (Settings.UpdateLibrary)
{ {

@ -2,16 +2,19 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using FluentValidation.Results; using FluentValidation.Results;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
using NzbDrone.Core.Validation; using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Notifications.Webhook namespace NzbDrone.Core.Notifications.Webhook
{ {
public class Webhook : NotificationBase<WebhookSettings> public class Webhook : WebhookBase<WebhookSettings>
{ {
private readonly IWebhookProxy _proxy; private readonly IWebhookProxy _proxy;
public Webhook(IWebhookProxy proxy) public Webhook(IWebhookProxy proxy, IConfigFileProvider configFileProvider)
: base(configFileProvider)
{ {
_proxy = proxy; _proxy = proxy;
} }
@ -20,129 +23,52 @@ namespace NzbDrone.Core.Notifications.Webhook
public override void OnGrab(GrabMessage message) public override void OnGrab(GrabMessage message)
{ {
var remoteAlbum = message.Album; _proxy.SendWebhook(BuildOnGrabPayload(message), Settings);
var quality = message.Quality;
var payload = new WebhookGrabPayload
{
EventType = WebhookEventType.Grab,
Artist = new WebhookArtist(message.Artist),
Albums = remoteAlbum.Albums.ConvertAll(x => new WebhookAlbum(x)
{
// TODO: Stop passing these parameters inside an album v3
Quality = quality.Quality.Name,
QualityVersion = quality.Revision.Version,
ReleaseGroup = remoteAlbum.ParsedAlbumInfo.ReleaseGroup
}),
Release = new WebhookRelease(quality, remoteAlbum),
DownloadClient = message.DownloadClient,
DownloadId = message.DownloadId
};
_proxy.SendWebhook(payload, Settings);
} }
public override void OnReleaseImport(AlbumDownloadMessage message) public override void OnReleaseImport(AlbumDownloadMessage message)
{ {
var trackFiles = message.TrackFiles; _proxy.SendWebhook(BuildOnReleaseImportPayload(message), Settings);
}
var payload = new WebhookImportPayload
{
EventType = WebhookEventType.Download,
Artist = new WebhookArtist(message.Artist),
Tracks = trackFiles.SelectMany(x => x.Tracks.Value.Select(y => new WebhookTrack(y)
{
// TODO: Stop passing these parameters inside an episode v3
Quality = x.Quality.Quality.Name,
QualityVersion = x.Quality.Revision.Version,
ReleaseGroup = x.ReleaseGroup
})).ToList(),
TrackFiles = trackFiles.ConvertAll(x => new WebhookTrackFile(x)),
IsUpgrade = message.OldFiles.Any(),
DownloadClient = message.DownloadClient,
DownloadId = message.DownloadId
};
if (message.OldFiles.Any())
{
payload.DeletedFiles = message.OldFiles.ConvertAll(x => new WebhookTrackFile(x));
}
_proxy.SendWebhook(payload, Settings); public override void OnDownloadFailure(DownloadFailedMessage message)
{
_proxy.SendWebhook(BuildOnDownloadFailurePayload(message), Settings);
} }
public override void OnRename(Artist artist) public override void OnImportFailure(AlbumDownloadMessage message)
{ {
var payload = new WebhookRenamePayload _proxy.SendWebhook(BuildOnImportFailurePayload(message), Settings);
{ }
EventType = WebhookEventType.Rename,
Artist = new WebhookArtist(artist)
};
_proxy.SendWebhook(payload, Settings); public override void OnRename(Artist artist, List<RenamedTrackFile> renamedFiles)
{
_proxy.SendWebhook(BuildOnRenamePayload(artist, renamedFiles), Settings);
} }
public override void OnTrackRetag(TrackRetagMessage message) public override void OnTrackRetag(TrackRetagMessage message)
{ {
var payload = new WebhookRetagPayload _proxy.SendWebhook(BuildOnTrackRetagPayload(message), Settings);
{
EventType = WebhookEventType.Retag,
Artist = new WebhookArtist(message.Artist),
TrackFile = new WebhookTrackFile(message.TrackFile)
};
_proxy.SendWebhook(payload, Settings);
} }
public override void OnAlbumDelete(AlbumDeleteMessage deleteMessage) public override void OnAlbumDelete(AlbumDeleteMessage deleteMessage)
{ {
var payload = new WebhookAlbumDeletePayload _proxy.SendWebhook(BuildOnAlbumDelete(deleteMessage), Settings);
{
EventType = WebhookEventType.AlbumDelete,
Album = new WebhookAlbum(deleteMessage.Album),
DeletedFiles = deleteMessage.DeletedFiles
};
_proxy.SendWebhook(payload, Settings);
} }
public override void OnArtistDelete(ArtistDeleteMessage deleteMessage) public override void OnArtistDelete(ArtistDeleteMessage deleteMessage)
{ {
var payload = new WebhookArtistDeletePayload _proxy.SendWebhook(BuildOnArtistDelete(deleteMessage), Settings);
{
EventType = WebhookEventType.ArtistDelete,
Artist = new WebhookArtist(deleteMessage.Artist),
DeletedFiles = deleteMessage.DeletedFiles
};
_proxy.SendWebhook(payload, Settings);
} }
public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck) public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
{ {
var payload = new WebhookHealthPayload _proxy.SendWebhook(BuildHealthPayload(healthCheck), Settings);
{
EventType = WebhookEventType.Health,
Level = healthCheck.Type,
Message = healthCheck.Message,
Type = healthCheck.Source.Name,
WikiUrl = healthCheck.WikiUrl?.ToString()
};
_proxy.SendWebhook(payload, Settings);
} }
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
{ {
var payload = new WebhookApplicationUpdatePayload _proxy.SendWebhook(BuildApplicationUpdatePayload(updateMessage), Settings);
{
EventType = WebhookEventType.ApplicationUpdate,
Message = updateMessage.Message,
PreviousVersion = updateMessage.PreviousVersion.ToString(),
NewVersion = updateMessage.NewVersion.ToString()
};
_proxy.SendWebhook(payload, Settings);
} }
public override string Name => "Webhook"; public override string Name => "Webhook";
@ -160,27 +86,7 @@ namespace NzbDrone.Core.Notifications.Webhook
{ {
try try
{ {
var payload = new WebhookGrabPayload _proxy.SendWebhook(BuildTestPayload(), Settings);
{
EventType = WebhookEventType.Test,
Artist = new WebhookArtist()
{
Id = 1,
Name = "Test Name",
Path = "C:\\testpath",
MBId = "aaaaa-aaa-aaaa-aaaaaa"
},
Albums = new List<WebhookAlbum>()
{
new WebhookAlbum()
{
Id = 123,
Title = "Test title"
}
}
};
_proxy.SendWebhook(payload, Settings);
} }
catch (WebhookException ex) catch (WebhookException ex)
{ {

@ -1,5 +1,3 @@
using NzbDrone.Core.HealthCheck;
namespace NzbDrone.Core.Notifications.Webhook namespace NzbDrone.Core.Notifications.Webhook
{ {
public class WebhookApplicationUpdatePayload : WebhookPayload public class WebhookApplicationUpdatePayload : WebhookPayload

@ -8,6 +8,7 @@ namespace NzbDrone.Core.Notifications.Webhook
public string Name { get; set; } public string Name { get; set; }
public string Path { get; set; } public string Path { get; set; }
public string MBId { get; set; } public string MBId { get; set; }
public string Type { get; set; }
public WebhookArtist() public WebhookArtist()
{ {
@ -18,6 +19,7 @@ namespace NzbDrone.Core.Notifications.Webhook
Id = artist.Id; Id = artist.Id;
Name = artist.Name; Name = artist.Name;
Path = artist.Path; Path = artist.Path;
Type = artist.Metadata.Value.Type;
MBId = artist.Metadata.Value.ForeignArtistId; MBId = artist.Metadata.Value.ForeignArtistId;
} }
} }

@ -0,0 +1,195 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Notifications.Webhook
{
public abstract class WebhookBase<TSettings> : NotificationBase<TSettings>
where TSettings : IProviderConfig, new()
{
private readonly IConfigFileProvider _configFileProvider;
protected WebhookBase(IConfigFileProvider configFileProvider)
: base()
{
_configFileProvider = configFileProvider;
}
public WebhookGrabPayload BuildOnGrabPayload(GrabMessage message)
{
var remoteAlbum = message.Album;
var quality = message.Quality;
return new WebhookGrabPayload
{
EventType = WebhookEventType.Grab,
InstanceName = _configFileProvider.InstanceName,
Artist = new WebhookArtist(message.Artist),
Release = new WebhookRelease(quality, remoteAlbum),
DownloadClient = message.DownloadClientName,
DownloadClientType = message.DownloadClientType,
DownloadId = message.DownloadId
};
}
public WebhookImportPayload BuildOnReleaseImportPayload(AlbumDownloadMessage message)
{
var trackFiles = message.TrackFiles;
var payload = new WebhookImportPayload
{
EventType = WebhookEventType.Download,
InstanceName = _configFileProvider.InstanceName,
Artist = new WebhookArtist(message.Artist),
Tracks = trackFiles.SelectMany(x => x.Tracks.Value.Select(y => new WebhookTrack(y))).ToList(),
TrackFiles = trackFiles.ConvertAll(x => new WebhookTrackFile(x)),
IsUpgrade = message.OldFiles.Any(),
DownloadClient = message.DownloadClientInfo?.Name,
DownloadClientType = message.DownloadClientInfo?.Type,
DownloadId = message.DownloadId
};
if (message.OldFiles.Any())
{
payload.DeletedFiles = message.OldFiles.ConvertAll(x => new WebhookTrackFile(x));
}
return payload;
}
public WebhookDownloadFailurePayload BuildOnDownloadFailurePayload(DownloadFailedMessage message)
{
return new WebhookDownloadFailurePayload
{
EventType = WebhookEventType.DownloadFailure,
InstanceName = _configFileProvider.InstanceName,
DownloadClient = message.DownloadClient,
DownloadId = message.DownloadId,
Quality = message.Quality.Quality.Name,
QualityVersion = message.Quality.Revision.Version,
ReleaseTitle = message.SourceTitle
};
}
public WebhookImportPayload BuildOnImportFailurePayload(AlbumDownloadMessage message)
{
var trackFiles = message.TrackFiles;
var payload = new WebhookImportPayload
{
EventType = WebhookEventType.ImportFailure,
InstanceName = _configFileProvider.InstanceName,
Artist = new WebhookArtist(message.Artist),
Tracks = trackFiles.SelectMany(x => x.Tracks.Value.Select(y => new WebhookTrack(y))).ToList(),
TrackFiles = trackFiles.ConvertAll(x => new WebhookTrackFile(x)),
IsUpgrade = message.OldFiles.Any(),
DownloadClient = message.DownloadClientInfo?.Name,
DownloadClientType = message.DownloadClientInfo?.Type,
DownloadId = message.DownloadId
};
if (message.OldFiles.Any())
{
payload.DeletedFiles = message.OldFiles.ConvertAll(x => new WebhookTrackFile(x));
}
return payload;
}
public WebhookRenamePayload BuildOnRenamePayload(Artist artist, List<RenamedTrackFile> renamedFiles)
{
return new WebhookRenamePayload
{
EventType = WebhookEventType.Rename,
InstanceName = _configFileProvider.InstanceName,
Artist = new WebhookArtist(artist),
RenamedTrackFiles = renamedFiles.ConvertAll(x => new WebhookRenamedTrackFile(x))
};
}
public WebhookRetagPayload BuildOnTrackRetagPayload(TrackRetagMessage message)
{
return new WebhookRetagPayload
{
EventType = WebhookEventType.Retag,
InstanceName = _configFileProvider.InstanceName,
Artist = new WebhookArtist(message.Artist),
TrackFile = new WebhookTrackFile(message.TrackFile)
};
}
public WebhookAlbumDeletePayload BuildOnAlbumDelete(AlbumDeleteMessage deleteMessage)
{
return new WebhookAlbumDeletePayload
{
EventType = WebhookEventType.AlbumDelete,
InstanceName = _configFileProvider.InstanceName,
Album = new WebhookAlbum(deleteMessage.Album),
DeletedFiles = deleteMessage.DeletedFiles
};
}
public WebhookArtistDeletePayload BuildOnArtistDelete(ArtistDeleteMessage deleteMessage)
{
return new WebhookArtistDeletePayload
{
EventType = WebhookEventType.ArtistDelete,
InstanceName = _configFileProvider.InstanceName,
Artist = new WebhookArtist(deleteMessage.Artist),
DeletedFiles = deleteMessage.DeletedFiles
};
}
protected WebhookHealthPayload BuildHealthPayload(HealthCheck.HealthCheck healthCheck)
{
return new WebhookHealthPayload
{
EventType = WebhookEventType.Health,
InstanceName = _configFileProvider.InstanceName,
Level = healthCheck.Type,
Message = healthCheck.Message,
Type = healthCheck.Source.Name,
WikiUrl = healthCheck.WikiUrl?.ToString()
};
}
protected WebhookApplicationUpdatePayload BuildApplicationUpdatePayload(ApplicationUpdateMessage updateMessage)
{
return new WebhookApplicationUpdatePayload
{
EventType = WebhookEventType.ApplicationUpdate,
InstanceName = _configFileProvider.InstanceName,
Message = updateMessage.Message,
PreviousVersion = updateMessage.PreviousVersion.ToString(),
NewVersion = updateMessage.NewVersion.ToString()
};
}
protected WebhookPayload BuildTestPayload()
{
return new WebhookGrabPayload
{
EventType = WebhookEventType.Test,
InstanceName = _configFileProvider.InstanceName,
Artist = new WebhookArtist()
{
Id = 1,
Name = "Test Name",
Path = "C:\\testpath",
MBId = "aaaaa-aaa-aaaa-aaaaaa"
},
Albums = new List<WebhookAlbum>()
{
new WebhookAlbum()
{
Id = 123,
Title = "Test title"
}
}
};
}
}
}

@ -0,0 +1,13 @@
using System.Collections.Generic;
namespace NzbDrone.Core.Notifications.Webhook
{
public class WebhookDownloadFailurePayload : WebhookPayload
{
public string Quality { get; set; }
public int QualityVersion { get; set; }
public string ReleaseTitle { get; set; }
public string DownloadClient { get; set; }
public string DownloadId { get; set; }
}
}

@ -11,6 +11,8 @@ namespace NzbDrone.Core.Notifications.Webhook
Test, Test,
Grab, Grab,
Download, Download,
DownloadFailure,
ImportFailure,
Rename, Rename,
AlbumDelete, AlbumDelete,
ArtistDelete, ArtistDelete,

@ -8,6 +8,7 @@ namespace NzbDrone.Core.Notifications.Webhook
public List<WebhookAlbum> Albums { get; set; } public List<WebhookAlbum> Albums { get; set; }
public WebhookRelease Release { get; set; } public WebhookRelease Release { get; set; }
public string DownloadClient { get; set; } public string DownloadClient { get; set; }
public string DownloadClientType { get; set; }
public string DownloadId { get; set; } public string DownloadId { get; set; }
} }
} }

@ -10,6 +10,7 @@ namespace NzbDrone.Core.Notifications.Webhook
public List<WebhookTrackFile> DeletedFiles { get; set; } public List<WebhookTrackFile> DeletedFiles { get; set; }
public bool IsUpgrade { get; set; } public bool IsUpgrade { get; set; }
public string DownloadClient { get; set; } public string DownloadClient { get; set; }
public string DownloadClientType { get; set; }
public string DownloadId { get; set; } public string DownloadId { get; set; }
} }
} }

@ -1,5 +1,3 @@
using NzbDrone.Common.Http;
namespace NzbDrone.Core.Notifications.Webhook namespace NzbDrone.Core.Notifications.Webhook
{ {
public enum WebhookMethod public enum WebhookMethod

@ -3,5 +3,6 @@ namespace NzbDrone.Core.Notifications.Webhook
public class WebhookPayload public class WebhookPayload
{ {
public WebhookEventType EventType { get; set; } public WebhookEventType EventType { get; set; }
public string InstanceName { get; set; }
} }
} }

@ -1,7 +1,10 @@
using System.Collections.Generic;
namespace NzbDrone.Core.Notifications.Webhook namespace NzbDrone.Core.Notifications.Webhook
{ {
public class WebhookRenamePayload : WebhookPayload public class WebhookRenamePayload : WebhookPayload
{ {
public WebhookArtist Artist { get; set; } public WebhookArtist Artist { get; set; }
public List<WebhookRenamedTrackFile> RenamedTrackFiles { get; set; }
} }
} }

@ -0,0 +1,15 @@
using NzbDrone.Core.MediaFiles;
namespace NzbDrone.Core.Notifications.Webhook
{
public class WebhookRenamedTrackFile : WebhookTrackFile
{
public WebhookRenamedTrackFile(RenamedTrackFile renamedMovie)
: base(renamedMovie.TrackFile)
{
PreviousPath = renamedMovie.PreviousPath;
}
public string PreviousPath { get; set; }
}
}

@ -4,6 +4,7 @@ using System.Net.Sockets;
using FluentValidation.Results; using FluentValidation.Results;
using NLog; using NLog;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
namespace NzbDrone.Core.Notifications.Xbmc namespace NzbDrone.Core.Notifications.Xbmc
@ -36,7 +37,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
UpdateAndClean(message.Artist, message.OldFiles.Any()); UpdateAndClean(message.Artist, message.OldFiles.Any());
} }
public override void OnRename(Artist artist) public override void OnRename(Artist artist, List<RenamedTrackFile> renamedFiles)
{ {
UpdateAndClean(artist); UpdateAndClean(artist);
} }

Loading…
Cancel
Save