mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 16:22:55 -07:00
Small refactorings
This commit is contained in:
parent
1067b9afd7
commit
83bb1b58e7
7 changed files with 41 additions and 46 deletions
|
@ -28,13 +28,17 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using Ninject;
|
||||
using Ninject.Planning.Bindings.Resolvers;
|
||||
|
||||
using Ninject.Syntax;
|
||||
using NLog;
|
||||
|
||||
using Owin;
|
||||
using PlexRequests.Api.Interfaces;
|
||||
using PlexRequests.Core;
|
||||
using PlexRequests.Core.Migration;
|
||||
using PlexRequests.Core.SettingModels;
|
||||
using PlexRequests.Services.Interfaces;
|
||||
using PlexRequests.Services.Jobs;
|
||||
using PlexRequests.Services.Notification;
|
||||
using PlexRequests.Store.Models;
|
||||
using PlexRequests.Store.Repository;
|
||||
using PlexRequests.UI.Helpers;
|
||||
|
@ -89,10 +93,8 @@ namespace PlexRequests.UI
|
|||
jobSettings.Update(scheduledJobse);
|
||||
}
|
||||
scheduler.StartScheduler();
|
||||
|
||||
|
||||
|
||||
|
||||
SubscribeAllObservers(kernel);
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
@ -101,5 +103,37 @@ namespace PlexRequests.UI
|
|||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void SubscribeAllObservers(IResolutionRoot container)
|
||||
{
|
||||
var notificationService = container.Get<INotificationService>();
|
||||
|
||||
var emailSettingsService = container.Get<ISettingsService<EmailNotificationSettings>>();
|
||||
var emailSettings = emailSettingsService.GetSettings();
|
||||
SubScribeOvserver(emailSettings, notificationService ,new EmailMessageNotification(emailSettingsService));
|
||||
|
||||
|
||||
var pushbulletService = container.Get<ISettingsService<PushbulletNotificationSettings>>();
|
||||
var pushbulletSettings = pushbulletService.GetSettings();
|
||||
SubScribeOvserver(pushbulletSettings, notificationService, new PushbulletNotification(container.Get<IPushbulletApi>(), pushbulletService));
|
||||
|
||||
|
||||
var pushoverService = container.Get<ISettingsService<PushoverNotificationSettings>>();
|
||||
var pushoverSettings = pushoverService.GetSettings();
|
||||
SubScribeOvserver(pushoverSettings, notificationService, new PushoverNotification(container.Get<IPushoverApi>(), pushoverService));
|
||||
|
||||
var slackService = container.Get<ISettingsService<SlackNotificationSettings>>();
|
||||
var slackSettings = slackService.GetSettings();
|
||||
SubScribeOvserver(slackSettings, notificationService, new SlackNotification(container.Get<ISlackApi>(), slackService));
|
||||
}
|
||||
|
||||
private void SubScribeOvserver<T>(T settings, INotificationService notificationService, INotification notification)
|
||||
where T : NotificationSettings
|
||||
{
|
||||
if (settings.Enabled)
|
||||
{
|
||||
notificationService.Subscribe(notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue