mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-20 21:54:58 -04:00
New: Notifications (Connect) Status
This commit is contained in:
@@ -32,11 +32,13 @@ namespace NzbDrone.Core.Notifications
|
||||
IHandleAsync<HealthCheckCompleteEvent>
|
||||
{
|
||||
private readonly INotificationFactory _notificationFactory;
|
||||
private readonly INotificationStatusService _notificationStatusService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public NotificationService(INotificationFactory notificationFactory, Logger logger)
|
||||
public NotificationService(INotificationFactory notificationFactory, INotificationStatusService notificationStatusService, Logger logger)
|
||||
{
|
||||
_notificationFactory = notificationFactory;
|
||||
_notificationStatusService = notificationStatusService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -136,9 +138,11 @@ namespace NzbDrone.Core.Notifications
|
||||
}
|
||||
|
||||
notification.OnGrab(grabMessage);
|
||||
_notificationStatusService.RecordSuccess(notification.Definition.Id);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_notificationStatusService.RecordFailure(notification.Definition.Id);
|
||||
_logger.Error(ex, "Unable to send OnGrab notification to {0}", notification.Definition.Name);
|
||||
}
|
||||
}
|
||||
@@ -173,11 +177,13 @@ namespace NzbDrone.Core.Notifications
|
||||
if (downloadMessage.OldFiles.Empty() || ((NotificationDefinition)notification.Definition).OnUpgrade)
|
||||
{
|
||||
notification.OnDownload(downloadMessage);
|
||||
_notificationStatusService.RecordSuccess(notification.Definition.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_notificationStatusService.RecordFailure(notification.Definition.Id);
|
||||
_logger.Warn(ex, "Unable to send OnDownload notification to: " + notification.Definition.Name);
|
||||
}
|
||||
}
|
||||
@@ -192,10 +198,12 @@ namespace NzbDrone.Core.Notifications
|
||||
if (ShouldHandleSeries(notification.Definition, message.Series))
|
||||
{
|
||||
notification.OnRename(message.Series, message.RenamedFiles);
|
||||
_notificationStatusService.RecordSuccess(notification.Definition.Id);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_notificationStatusService.RecordFailure(notification.Definition.Id);
|
||||
_logger.Warn(ex, "Unable to send OnRename notification to: " + notification.Definition.Name);
|
||||
}
|
||||
}
|
||||
@@ -213,9 +221,11 @@ namespace NzbDrone.Core.Notifications
|
||||
try
|
||||
{
|
||||
notification.OnApplicationUpdate(updateMessage);
|
||||
_notificationStatusService.RecordSuccess(notification.Definition.Id);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_notificationStatusService.RecordFailure(notification.Definition.Id);
|
||||
_logger.Warn(ex, "Unable to send OnApplicationUpdate notification to: " + notification.Definition.Name);
|
||||
}
|
||||
}
|
||||
@@ -246,9 +256,11 @@ namespace NzbDrone.Core.Notifications
|
||||
}
|
||||
|
||||
notification.OnManualInteractionRequired(manualInteractionMessage);
|
||||
_notificationStatusService.RecordSuccess(notification.Definition.Id);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_notificationStatusService.RecordFailure(notification.Definition.Id);
|
||||
_logger.Error(ex, "Unable to send OnManualInteractionRequired notification to {0}", notification.Definition.Name);
|
||||
}
|
||||
}
|
||||
@@ -278,11 +290,13 @@ namespace NzbDrone.Core.Notifications
|
||||
if (ShouldHandleSeries(notification.Definition, deleteMessage.EpisodeFile.Series))
|
||||
{
|
||||
notification.OnEpisodeFileDelete(deleteMessage);
|
||||
_notificationStatusService.RecordSuccess(notification.Definition.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_notificationStatusService.RecordFailure(notification.Definition.Id);
|
||||
_logger.Warn(ex, "Unable to send OnEpisodeFileDelete notification to: " + notification.Definition.Name);
|
||||
}
|
||||
}
|
||||
@@ -304,10 +318,12 @@ namespace NzbDrone.Core.Notifications
|
||||
if (ShouldHandleSeries(notification.Definition, series))
|
||||
{
|
||||
notification.OnSeriesAdd(addMessage);
|
||||
_notificationStatusService.RecordSuccess(notification.Definition.Id);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_notificationStatusService.RecordFailure(notification.Definition.Id);
|
||||
_logger.Warn(ex, "Unable to send OnSeriesAdd notification to: " + notification.Definition.Name);
|
||||
}
|
||||
}
|
||||
@@ -326,10 +342,12 @@ namespace NzbDrone.Core.Notifications
|
||||
if (ShouldHandleSeries(notification.Definition, deleteMessage.Series))
|
||||
{
|
||||
notification.OnSeriesDelete(deleteMessage);
|
||||
_notificationStatusService.RecordSuccess(notification.Definition.Id);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_notificationStatusService.RecordFailure(notification.Definition.Id);
|
||||
_logger.Warn(ex, "Unable to send OnSeriesDelete notification to: " + notification.Definition.Name);
|
||||
}
|
||||
}
|
||||
@@ -353,10 +371,12 @@ namespace NzbDrone.Core.Notifications
|
||||
if (ShouldHandleHealthFailure(message.HealthCheck, ((NotificationDefinition)notification.Definition).IncludeHealthWarnings))
|
||||
{
|
||||
notification.OnHealthIssue(message.HealthCheck);
|
||||
_notificationStatusService.RecordSuccess(notification.Definition.Id);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_notificationStatusService.RecordFailure(notification.Definition.Id);
|
||||
_logger.Warn(ex, "Unable to send OnHealthIssue notification to: " + notification.Definition.Name);
|
||||
}
|
||||
}
|
||||
@@ -376,10 +396,12 @@ namespace NzbDrone.Core.Notifications
|
||||
if (ShouldHandleHealthFailure(message.PreviousCheck, ((NotificationDefinition)notification.Definition).IncludeHealthWarnings))
|
||||
{
|
||||
notification.OnHealthRestored(message.PreviousCheck);
|
||||
_notificationStatusService.RecordSuccess(notification.Definition.Id);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_notificationStatusService.RecordFailure(notification.Definition.Id);
|
||||
_logger.Warn(ex, "Unable to send OnHealthRestored notification to: " + notification.Definition.Name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user