mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 05:23:31 -07:00
Notifications wired up server sided
This commit is contained in:
parent
3f44339381
commit
e9bf78a97d
57 changed files with 977 additions and 951 deletions
31
NzbDrone.Core/Notifications/NotificationSettingsProvider.cs
Normal file
31
NzbDrone.Core/Notifications/NotificationSettingsProvider.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using Newtonsoft.Json;
|
||||
|
||||
namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
public interface INotificationSettingsProvider
|
||||
{
|
||||
TSetting Get<TSetting>(INotification indexer) where TSetting : INotifcationSettings, new();
|
||||
}
|
||||
|
||||
public class NotificationSettingsProvider : INotificationSettingsProvider
|
||||
{
|
||||
private readonly INotificationRepository _notificationRepository;
|
||||
|
||||
public NotificationSettingsProvider(INotificationRepository notificationRepository)
|
||||
{
|
||||
_notificationRepository = notificationRepository;
|
||||
}
|
||||
|
||||
public TSetting Get<TSetting>(INotification indexer) where TSetting : INotifcationSettings, new()
|
||||
{
|
||||
var indexerDef = _notificationRepository.Find(indexer.Name);
|
||||
|
||||
if (indexerDef == null || string.IsNullOrWhiteSpace(indexerDef.Settings))
|
||||
{
|
||||
return new TSetting();
|
||||
}
|
||||
|
||||
return JsonConvert.DeserializeObject<TSetting>(indexerDef.Settings);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue