mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
#96 modify notifications interface/service to accept a non-type specific settings object.
This commit is contained in:
parent
4b3f79b4a8
commit
45208e528f
6 changed files with 13 additions and 11 deletions
|
@ -37,6 +37,6 @@ namespace PlexRequests.Services.Interfaces
|
||||||
|
|
||||||
Task NotifyAsync(NotificationModel model);
|
Task NotifyAsync(NotificationModel model);
|
||||||
|
|
||||||
Task NotifyAsync(NotificationModel model, EmailNotificationSettings settings);
|
Task NotifyAsync(NotificationModel model, Settings settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,7 +34,7 @@ namespace PlexRequests.Services.Interfaces
|
||||||
public interface INotificationService
|
public interface INotificationService
|
||||||
{
|
{
|
||||||
Task Publish(NotificationModel model);
|
Task Publish(NotificationModel model);
|
||||||
Task Publish(NotificationModel model, EmailNotificationSettings settings);
|
Task Publish(NotificationModel model, Settings settings);
|
||||||
void Subscribe(INotification notification);
|
void Subscribe(INotification notification);
|
||||||
void UnSubscribe(INotification notification);
|
void UnSubscribe(INotification notification);
|
||||||
|
|
||||||
|
|
|
@ -54,11 +54,13 @@ namespace PlexRequests.Services.Notification
|
||||||
await NotifyAsync(model, configuration);
|
await NotifyAsync(model, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task NotifyAsync(NotificationModel model, EmailNotificationSettings settings)
|
public async Task NotifyAsync(NotificationModel model, Settings settings)
|
||||||
{
|
{
|
||||||
if (settings == null) await NotifyAsync(model);
|
if (settings == null) await NotifyAsync(model);
|
||||||
|
|
||||||
if (!ValidateConfiguration(settings))
|
var emailSettings = (EmailNotificationSettings)settings;
|
||||||
|
|
||||||
|
if (!ValidateConfiguration(emailSettings))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -66,10 +68,10 @@ namespace PlexRequests.Services.Notification
|
||||||
switch (model.NotificationType)
|
switch (model.NotificationType)
|
||||||
{
|
{
|
||||||
case NotificationType.NewRequest:
|
case NotificationType.NewRequest:
|
||||||
await EmailNewRequest(model, settings);
|
await EmailNewRequest(model, emailSettings);
|
||||||
break;
|
break;
|
||||||
case NotificationType.Issue:
|
case NotificationType.Issue:
|
||||||
await EmailIssue(model, settings);
|
await EmailIssue(model, emailSettings);
|
||||||
break;
|
break;
|
||||||
case NotificationType.RequestAvailable:
|
case NotificationType.RequestAvailable:
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
@ -81,7 +83,7 @@ namespace PlexRequests.Services.Notification
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|
||||||
case NotificationType.Test:
|
case NotificationType.Test:
|
||||||
await EmailTest(model, settings);
|
await EmailTest(model, emailSettings);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace PlexRequests.Services.Notification
|
||||||
await Task.WhenAll(notificationTasks).ConfigureAwait(false);
|
await Task.WhenAll(notificationTasks).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Publish(NotificationModel model, EmailNotificationSettings settings)
|
public async Task Publish(NotificationModel model, Settings settings)
|
||||||
{
|
{
|
||||||
var notificationTasks = Observers.Values.Select(notification => NotifyAsync(notification, model, settings));
|
var notificationTasks = Observers.Values.Select(notification => NotifyAsync(notification, model, settings));
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ namespace PlexRequests.Services.Notification
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task NotifyAsync(INotification notification, NotificationModel model, EmailNotificationSettings settings)
|
private static async Task NotifyAsync(INotification notification, NotificationModel model, Settings settings)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -129,7 +129,7 @@ namespace PlexRequests.Services.Notification
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task NotifyAsync(NotificationModel model, EmailNotificationSettings settings)
|
public Task NotifyAsync(NotificationModel model, Settings settings)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ namespace PlexRequests.Services.Notification
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task NotifyAsync(NotificationModel model, EmailNotificationSettings settings)
|
public Task NotifyAsync(NotificationModel model, Settings settings)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue