diff --git a/Ombi.Services/Interfaces/INotificationService.cs b/Ombi.Services/Interfaces/INotificationService.cs index 6eb2d238c..2a40a722c 100644 --- a/Ombi.Services/Interfaces/INotificationService.cs +++ b/Ombi.Services/Interfaces/INotificationService.cs @@ -39,6 +39,7 @@ namespace Ombi.Services.Interfaces /// The model. /// Task Publish(NotificationModel model); + Task PublishTest(NotificationModel model, Settings settings, INotification type); /// /// Sends a notification to the user, this is usually for testing the settings. /// diff --git a/Ombi.Services/Notification/NotificationService.cs b/Ombi.Services/Notification/NotificationService.cs index 15622427a..4b19d3bb7 100644 --- a/Ombi.Services/Notification/NotificationService.cs +++ b/Ombi.Services/Notification/NotificationService.cs @@ -100,5 +100,10 @@ namespace Ombi.Services.Notification throw new InvalidOperationException(ex.Message); } } + + public async Task PublishTest(NotificationModel model, Settings settings, INotification type) + { + await type.NotifyAsync(model, settings); + } } } \ No newline at end of file diff --git a/Ombi.UI/Modules/Admin/AdminModule.cs b/Ombi.UI/Modules/Admin/AdminModule.cs index 307e501df..72f60612e 100644 --- a/Ombi.UI/Modules/Admin/AdminModule.cs +++ b/Ombi.UI/Modules/Admin/AdminModule.cs @@ -639,7 +639,7 @@ namespace Ombi.UI.Modules.Admin { NotificationService.Subscribe(new EmailMessageNotification(EmailService)); settings.Enabled = true; - await NotificationService.Publish(notificationModel, settings); + await NotificationService.PublishTest(notificationModel, settings, new EmailMessageNotification(EmailService)); Log.Info("Sent email notification test"); } catch (Exception ex) @@ -743,7 +743,7 @@ namespace Ombi.UI.Modules.Admin { NotificationService.Subscribe(new PushbulletNotification(PushbulletApi, PushbulletService)); settings.Enabled = true; - await NotificationService.Publish(notificationModel, settings); + await NotificationService.PublishTest(notificationModel, settings, new PushbulletNotification(PushbulletApi, PushbulletService)); Log.Info("Sent pushbullet notification test"); } catch (Exception) @@ -809,7 +809,7 @@ namespace Ombi.UI.Modules.Admin { NotificationService.Subscribe(new PushoverNotification(PushoverApi, PushoverService)); settings.Enabled = true; - await NotificationService.Publish(notificationModel, settings); + await NotificationService.PublishTest(notificationModel, settings, new PushoverNotification(PushoverApi, PushoverService)); Log.Info("Sent pushover notification test"); } catch (Exception) @@ -1004,7 +1004,7 @@ namespace Ombi.UI.Modules.Admin { NotificationService.Subscribe(new SlackNotification(SlackApi, SlackSettings)); settings.Enabled = true; - await NotificationService.Publish(notificationModel, settings); + await NotificationService.PublishTest(notificationModel, settings, new SlackNotification(SlackApi, SlackSettings)); Log.Info("Sent slack notification test"); } catch (Exception e) @@ -1075,7 +1075,7 @@ namespace Ombi.UI.Modules.Admin { NotificationService.Subscribe(new DiscordNotification(DiscordApi, DiscordSettings)); settings.Enabled = true; - await NotificationService.Publish(notificationModel, settings); + await NotificationService.PublishTest(notificationModel, settings, new DiscordNotification(DiscordApi, DiscordSettings)); Log.Info("Sent Discord notification test"); } catch (Exception e)