mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 17:13:49 -07:00
Notification schema added to server side.
This commit is contained in:
parent
fea10997ad
commit
482cbc20a3
6 changed files with 152 additions and 1 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue