mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-18 21:35:51 -04:00
Notifications wired up server sided
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user