From 493114f4e85fe874044ef04d4940972e5148a4ec Mon Sep 17 00:00:00 2001 From: Bogdan Date: Fri, 10 Nov 2023 04:55:01 +0200 Subject: [PATCH] Fixed: Record status for notifications on tests --- .../Notifications/NotificationFactory.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/NzbDrone.Core/Notifications/NotificationFactory.cs b/src/NzbDrone.Core/Notifications/NotificationFactory.cs index ffdbd482c..f9d79940e 100644 --- a/src/NzbDrone.Core/Notifications/NotificationFactory.cs +++ b/src/NzbDrone.Core/Notifications/NotificationFactory.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using FluentValidation.Results; using NLog; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.ThingiProvider; @@ -97,5 +98,26 @@ namespace NzbDrone.Core.Notifications definition.SupportsOnHealthRestored = provider.SupportsOnHealthRestored; definition.SupportsOnApplicationUpdate = provider.SupportsOnApplicationUpdate; } + + public override ValidationResult Test(NotificationDefinition definition) + { + var result = base.Test(definition); + + if (definition.Id == 0) + { + return result; + } + + if (result == null || result.IsValid) + { + _notificationStatusService.RecordSuccess(definition.Id); + } + else + { + _notificationStatusService.RecordFailure(definition.Id); + } + + return result; + } } }