mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Notification schema added to server side.
This commit is contained in:
@@ -15,6 +15,7 @@ namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
List<Notification> All();
|
||||
Notification Get(int id);
|
||||
List<Notification> Schema();
|
||||
}
|
||||
|
||||
public class NotificationService
|
||||
@@ -49,6 +50,32 @@ namespace NzbDrone.Core.Notifications
|
||||
return ToNotification(_notificationRepository.Get(id));
|
||||
}
|
||||
|
||||
public List<Notification> Schema()
|
||||
{
|
||||
var notifications = new List<Notification>();
|
||||
|
||||
int i = 1;
|
||||
foreach (var notification in _notifications)
|
||||
{
|
||||
i++;
|
||||
var type = notification.GetType();
|
||||
|
||||
var newNotification = new Notification();
|
||||
newNotification.Instance = (INotification)_container.Resolve(type);
|
||||
newNotification.Id = i;
|
||||
newNotification.Name = notification.Name;
|
||||
|
||||
var instanceType = newNotification.Instance.GetType();
|
||||
var baseGenArgs = instanceType.BaseType.GetGenericArguments();
|
||||
newNotification.Settings = (INotifcationSettings) Activator.CreateInstance(baseGenArgs[0]);
|
||||
newNotification.Implementation = type.Name;
|
||||
|
||||
notifications.Add(newNotification);
|
||||
}
|
||||
|
||||
return notifications;
|
||||
}
|
||||
|
||||
private Notification ToNotification(NotificationDefinition definition)
|
||||
{
|
||||
var notification = new Notification();
|
||||
|
Reference in New Issue
Block a user