mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 08:16:05 -07:00
#96 Email notification test button (others to come)
This commit is contained in:
parent
085c46ce43
commit
4b3f79b4a8
9 changed files with 134 additions and 18 deletions
|
@ -32,6 +32,7 @@ using System.Threading.Tasks;
|
|||
using NLog;
|
||||
|
||||
using PlexRequests.Services.Interfaces;
|
||||
using PlexRequests.Core.SettingModels;
|
||||
|
||||
namespace PlexRequests.Services.Notification
|
||||
{
|
||||
|
@ -47,6 +48,13 @@ namespace PlexRequests.Services.Notification
|
|||
await Task.WhenAll(notificationTasks).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task Publish(NotificationModel model, EmailNotificationSettings settings)
|
||||
{
|
||||
var notificationTasks = Observers.Values.Select(notification => NotifyAsync(notification, model, settings));
|
||||
|
||||
await Task.WhenAll(notificationTasks).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public void Subscribe(INotification notification)
|
||||
{
|
||||
Observers.TryAdd(notification.NotificationName, notification);
|
||||
|
@ -58,10 +66,17 @@ namespace PlexRequests.Services.Notification
|
|||
}
|
||||
|
||||
private static async Task NotifyAsync(INotification notification, NotificationModel model)
|
||||
{
|
||||
|
||||
await NotifyAsync(notification, model, null);
|
||||
|
||||
}
|
||||
|
||||
private static async Task NotifyAsync(INotification notification, NotificationModel model, EmailNotificationSettings settings)
|
||||
{
|
||||
try
|
||||
{
|
||||
await notification.NotifyAsync(model).ConfigureAwait(false);
|
||||
await notification.NotifyAsync(model, settings).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue