mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-14 09:12:57 -07:00
Fixed the notifications issue
This commit is contained in:
parent
96e3e88261
commit
181bd53202
22 changed files with 210 additions and 177 deletions
|
@ -318,7 +318,7 @@ namespace Ombi.Core.Engine
|
||||||
request.Denied = true;
|
request.Denied = true;
|
||||||
request.DeniedReason = denyReason;
|
request.DeniedReason = denyReason;
|
||||||
// We are denying a request
|
// We are denying a request
|
||||||
NotificationHelper.Notify(request, NotificationType.RequestDeclined);
|
await NotificationHelper.Notify(request, NotificationType.RequestDeclined);
|
||||||
await MovieRepository.Update(request);
|
await MovieRepository.Update(request);
|
||||||
|
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
|
@ -346,7 +346,7 @@ namespace Ombi.Core.Engine
|
||||||
var canNotify = await RunSpecificRule(request, SpecificRules.CanSendNotification);
|
var canNotify = await RunSpecificRule(request, SpecificRules.CanSendNotification);
|
||||||
if (canNotify.Success)
|
if (canNotify.Success)
|
||||||
{
|
{
|
||||||
NotificationHelper.Notify(request, NotificationType.RequestApproved);
|
await NotificationHelper.Notify(request, NotificationType.RequestApproved);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.Approved)
|
if (request.Approved)
|
||||||
|
@ -462,7 +462,7 @@ namespace Ombi.Core.Engine
|
||||||
|
|
||||||
request.Available = true;
|
request.Available = true;
|
||||||
request.MarkedAsAvailable = DateTime.Now;
|
request.MarkedAsAvailable = DateTime.Now;
|
||||||
NotificationHelper.Notify(request, NotificationType.RequestAvailable);
|
await NotificationHelper.Notify(request, NotificationType.RequestAvailable);
|
||||||
await MovieRepository.Update(request);
|
await MovieRepository.Update(request);
|
||||||
|
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
|
@ -478,8 +478,8 @@ namespace Ombi.Core.Engine
|
||||||
|
|
||||||
var result = await RunSpecificRule(model, SpecificRules.CanSendNotification);
|
var result = await RunSpecificRule(model, SpecificRules.CanSendNotification);
|
||||||
if (result.Success)
|
if (result.Success)
|
||||||
{
|
{
|
||||||
NotificationHelper.NewRequest(model);
|
await NotificationHelper.NewRequest(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _requestLog.Add(new RequestLog
|
await _requestLog.Add(new RequestLog
|
||||||
|
|
|
@ -314,7 +314,7 @@ namespace Ombi.Core.Engine
|
||||||
request.Denied = true;
|
request.Denied = true;
|
||||||
request.DeniedReason = reason;
|
request.DeniedReason = reason;
|
||||||
// We are denying a request
|
// We are denying a request
|
||||||
NotificationHelper.Notify(request, NotificationType.RequestDeclined);
|
await NotificationHelper.Notify(request, NotificationType.RequestDeclined);
|
||||||
await MusicRepository.Update(request);
|
await MusicRepository.Update(request);
|
||||||
|
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
|
@ -342,7 +342,7 @@ namespace Ombi.Core.Engine
|
||||||
var canNotify = await RunSpecificRule(request, SpecificRules.CanSendNotification);
|
var canNotify = await RunSpecificRule(request, SpecificRules.CanSendNotification);
|
||||||
if (canNotify.Success)
|
if (canNotify.Success)
|
||||||
{
|
{
|
||||||
NotificationHelper.Notify(request, NotificationType.RequestApproved);
|
await NotificationHelper.Notify(request, NotificationType.RequestApproved);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.Approved)
|
if (request.Approved)
|
||||||
|
@ -469,7 +469,7 @@ namespace Ombi.Core.Engine
|
||||||
|
|
||||||
request.Available = true;
|
request.Available = true;
|
||||||
request.MarkedAsAvailable = DateTime.Now;
|
request.MarkedAsAvailable = DateTime.Now;
|
||||||
NotificationHelper.Notify(request, NotificationType.RequestAvailable);
|
await NotificationHelper.Notify(request, NotificationType.RequestAvailable);
|
||||||
await MusicRepository.Update(request);
|
await MusicRepository.Update(request);
|
||||||
|
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
|
@ -486,7 +486,7 @@ namespace Ombi.Core.Engine
|
||||||
var result = await RunSpecificRule(model, SpecificRules.CanSendNotification);
|
var result = await RunSpecificRule(model, SpecificRules.CanSendNotification);
|
||||||
if (result.Success)
|
if (result.Success)
|
||||||
{
|
{
|
||||||
NotificationHelper.NewRequest(model);
|
await NotificationHelper.NewRequest(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _requestLog.Add(new RequestLog
|
await _requestLog.Add(new RequestLog
|
||||||
|
|
|
@ -159,7 +159,6 @@ namespace Ombi.Core.Engine
|
||||||
|
|
||||||
}
|
}
|
||||||
await CheckForSubscription(shouldHide, allRequests);
|
await CheckForSubscription(shouldHide, allRequests);
|
||||||
allRequests.ForEach(async r => { });
|
|
||||||
|
|
||||||
return new RequestsViewModel<TvRequests>
|
return new RequestsViewModel<TvRequests>
|
||||||
{
|
{
|
||||||
|
@ -389,7 +388,7 @@ namespace Ombi.Core.Engine
|
||||||
|
|
||||||
if (request.Approved)
|
if (request.Approved)
|
||||||
{
|
{
|
||||||
NotificationHelper.Notify(request, NotificationType.RequestApproved);
|
await NotificationHelper.Notify(request, NotificationType.RequestApproved);
|
||||||
// Autosend
|
// Autosend
|
||||||
await TvSender.Send(request);
|
await TvSender.Send(request);
|
||||||
}
|
}
|
||||||
|
@ -412,7 +411,7 @@ namespace Ombi.Core.Engine
|
||||||
request.Denied = true;
|
request.Denied = true;
|
||||||
request.DeniedReason = reason;
|
request.DeniedReason = reason;
|
||||||
await TvRepository.UpdateChild(request);
|
await TvRepository.UpdateChild(request);
|
||||||
NotificationHelper.Notify(request, NotificationType.RequestDeclined);
|
await NotificationHelper.Notify(request, NotificationType.RequestDeclined);
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
{
|
{
|
||||||
Result = true
|
Result = true
|
||||||
|
@ -500,7 +499,7 @@ namespace Ombi.Core.Engine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await TvRepository.UpdateChild(request);
|
await TvRepository.UpdateChild(request);
|
||||||
NotificationHelper.Notify(request, NotificationType.RequestAvailable);
|
await NotificationHelper.Notify(request, NotificationType.RequestAvailable);
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
{
|
{
|
||||||
Result = true,
|
Result = true,
|
||||||
|
@ -585,7 +584,7 @@ namespace Ombi.Core.Engine
|
||||||
var sendRuleResult = await RunSpecificRule(model, SpecificRules.CanSendNotification);
|
var sendRuleResult = await RunSpecificRule(model, SpecificRules.CanSendNotification);
|
||||||
if (sendRuleResult.Success)
|
if (sendRuleResult.Success)
|
||||||
{
|
{
|
||||||
NotificationHelper.NewRequest(model);
|
await NotificationHelper.NewRequest(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _requestLog.Add(new RequestLog
|
await _requestLog.Add(new RequestLog
|
||||||
|
@ -600,7 +599,7 @@ namespace Ombi.Core.Engine
|
||||||
if (model.Approved)
|
if (model.Approved)
|
||||||
{
|
{
|
||||||
// Autosend
|
// Autosend
|
||||||
NotificationHelper.Notify(model, NotificationType.RequestApproved);
|
await NotificationHelper.Notify(model, NotificationType.RequestApproved);
|
||||||
var result = await TvSender.Send(model);
|
var result = await TvSender.Send(model);
|
||||||
if (result.Success)
|
if (result.Success)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using Hangfire;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Ombi.Core.Notifications;
|
using Ombi.Core.Notifications;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Notifications.Models;
|
using Ombi.Notifications.Models;
|
||||||
|
@ -9,13 +10,7 @@ namespace Ombi.Core
|
||||||
{
|
{
|
||||||
public class NotificationHelper : INotificationHelper
|
public class NotificationHelper : INotificationHelper
|
||||||
{
|
{
|
||||||
public NotificationHelper(INotificationService service)
|
public async Task NewRequest(FullBaseRequest model)
|
||||||
{
|
|
||||||
NotificationService = service;
|
|
||||||
}
|
|
||||||
private INotificationService NotificationService { get; }
|
|
||||||
|
|
||||||
public void NewRequest(FullBaseRequest model)
|
|
||||||
{
|
{
|
||||||
var notificationModel = new NotificationOptions
|
var notificationModel = new NotificationOptions
|
||||||
{
|
{
|
||||||
|
@ -24,11 +19,13 @@ namespace Ombi.Core
|
||||||
NotificationType = NotificationType.NewRequest,
|
NotificationType = NotificationType.NewRequest,
|
||||||
RequestType = model.RequestType
|
RequestType = model.RequestType
|
||||||
};
|
};
|
||||||
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
|
await OmbiQuartz.TriggerJob(nameof(INotificationService), "Notifications", new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{JobDataKeys.NotificationOptions, notificationModel}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NewRequest(ChildRequests model)
|
public async Task NewRequest(ChildRequests model)
|
||||||
{
|
{
|
||||||
var notificationModel = new NotificationOptions
|
var notificationModel = new NotificationOptions
|
||||||
{
|
{
|
||||||
|
@ -36,11 +33,14 @@ namespace Ombi.Core
|
||||||
DateTime = DateTime.Now,
|
DateTime = DateTime.Now,
|
||||||
NotificationType = NotificationType.NewRequest,
|
NotificationType = NotificationType.NewRequest,
|
||||||
RequestType = model.RequestType
|
RequestType = model.RequestType
|
||||||
};
|
};
|
||||||
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
|
await OmbiQuartz.TriggerJob(nameof(INotificationService), "Notifications", new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{JobDataKeys.NotificationOptions, notificationModel}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NewRequest(AlbumRequest model)
|
public async Task NewRequest(AlbumRequest model)
|
||||||
{
|
{
|
||||||
var notificationModel = new NotificationOptions
|
var notificationModel = new NotificationOptions
|
||||||
{
|
{
|
||||||
|
@ -48,38 +48,15 @@ namespace Ombi.Core
|
||||||
DateTime = DateTime.Now,
|
DateTime = DateTime.Now,
|
||||||
NotificationType = NotificationType.NewRequest,
|
NotificationType = NotificationType.NewRequest,
|
||||||
RequestType = model.RequestType
|
RequestType = model.RequestType
|
||||||
};
|
};
|
||||||
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
|
await OmbiQuartz.TriggerJob(nameof(INotificationService), "Notifications", new Dictionary<string, object>
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void Notify(MovieRequests model, NotificationType type)
|
|
||||||
{
|
|
||||||
var notificationModel = new NotificationOptions
|
|
||||||
{
|
{
|
||||||
RequestId = model.Id,
|
{JobDataKeys.NotificationOptions, notificationModel}
|
||||||
DateTime = DateTime.Now,
|
});
|
||||||
NotificationType = type,
|
|
||||||
RequestType = model.RequestType,
|
|
||||||
Recipient = model.RequestedUser?.Email ?? string.Empty
|
|
||||||
};
|
|
||||||
|
|
||||||
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
|
|
||||||
}
|
|
||||||
public void Notify(ChildRequests model, NotificationType type)
|
|
||||||
{
|
|
||||||
var notificationModel = new NotificationOptions
|
|
||||||
{
|
|
||||||
RequestId = model.Id,
|
|
||||||
DateTime = DateTime.Now,
|
|
||||||
NotificationType = type,
|
|
||||||
RequestType = model.RequestType,
|
|
||||||
Recipient = model.RequestedUser?.Email ?? string.Empty
|
|
||||||
};
|
|
||||||
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Notify(AlbumRequest model, NotificationType type)
|
|
||||||
|
public async Task Notify(MovieRequests model, NotificationType type)
|
||||||
{
|
{
|
||||||
var notificationModel = new NotificationOptions
|
var notificationModel = new NotificationOptions
|
||||||
{
|
{
|
||||||
|
@ -90,7 +67,50 @@ namespace Ombi.Core
|
||||||
Recipient = model.RequestedUser?.Email ?? string.Empty
|
Recipient = model.RequestedUser?.Email ?? string.Empty
|
||||||
};
|
};
|
||||||
|
|
||||||
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
|
await OmbiQuartz.TriggerJob(nameof(INotificationService), "Notifications", new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{JobDataKeys.NotificationOptions, notificationModel}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public async Task Notify(ChildRequests model, NotificationType type)
|
||||||
|
{
|
||||||
|
var notificationModel = new NotificationOptions
|
||||||
|
{
|
||||||
|
RequestId = model.Id,
|
||||||
|
DateTime = DateTime.Now,
|
||||||
|
NotificationType = type,
|
||||||
|
RequestType = model.RequestType,
|
||||||
|
Recipient = model.RequestedUser?.Email ?? string.Empty
|
||||||
|
};
|
||||||
|
await OmbiQuartz.TriggerJob(nameof(INotificationService), "Notifications", new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{JobDataKeys.NotificationOptions, notificationModel}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Notify(AlbumRequest model, NotificationType type)
|
||||||
|
{
|
||||||
|
var notificationModel = new NotificationOptions
|
||||||
|
{
|
||||||
|
RequestId = model.Id,
|
||||||
|
DateTime = DateTime.Now,
|
||||||
|
NotificationType = type,
|
||||||
|
RequestType = model.RequestType,
|
||||||
|
Recipient = model.RequestedUser?.Email ?? string.Empty
|
||||||
|
};
|
||||||
|
|
||||||
|
await OmbiQuartz.TriggerJob(nameof(INotificationService), "Notifications", new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{JobDataKeys.NotificationOptions, notificationModel}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Notify(NotificationOptions model)
|
||||||
|
{
|
||||||
|
await OmbiQuartz.TriggerJob(nameof(INotificationService), "Notifications", new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{JobDataKeys.NotificationOptions, model}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,16 +1,19 @@
|
||||||
using Ombi.Core.Models.Requests;
|
using System.Threading.Tasks;
|
||||||
|
using Ombi.Core.Models.Requests;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
|
using Ombi.Notifications.Models;
|
||||||
using Ombi.Store.Entities.Requests;
|
using Ombi.Store.Entities.Requests;
|
||||||
|
|
||||||
namespace Ombi.Core
|
namespace Ombi.Core
|
||||||
{
|
{
|
||||||
public interface INotificationHelper
|
public interface INotificationHelper
|
||||||
{
|
{
|
||||||
void NewRequest(FullBaseRequest model);
|
Task NewRequest(FullBaseRequest model);
|
||||||
void NewRequest(ChildRequests model);
|
Task NewRequest(ChildRequests model);
|
||||||
void NewRequest(AlbumRequest model);
|
Task NewRequest(AlbumRequest model);
|
||||||
void Notify(MovieRequests model, NotificationType type);
|
Task Notify(MovieRequests model, NotificationType type);
|
||||||
void Notify(ChildRequests model, NotificationType type);
|
Task Notify(ChildRequests model, NotificationType type);
|
||||||
void Notify(AlbumRequest model, NotificationType type);
|
Task Notify(AlbumRequest model, NotificationType type);
|
||||||
|
Task Notify(NotificationOptions model);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -95,7 +95,7 @@ namespace Ombi.Core.Senders
|
||||||
Type = RequestType.Movie,
|
Type = RequestType.Movie,
|
||||||
RetryCount = 0
|
RetryCount = 0
|
||||||
});
|
});
|
||||||
_notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
|
await _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace Ombi.Core.Senders
|
||||||
Type = RequestType.Album,
|
Type = RequestType.Album,
|
||||||
RetryCount = 0
|
RetryCount = 0
|
||||||
});
|
});
|
||||||
_notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
|
await _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ namespace Ombi.Core.Senders
|
||||||
Type = RequestType.TvShow,
|
Type = RequestType.TvShow,
|
||||||
RetryCount = 0
|
RetryCount = 0
|
||||||
});
|
});
|
||||||
_notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
|
await _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,8 @@ namespace Ombi.DependencyInjection
|
||||||
|
|
||||||
public static void RegisterJobs(this IServiceCollection services)
|
public static void RegisterJobs(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddSingleton<IJobFactory, IoCJobFactory>(provider => new IoCJobFactory(provider));
|
services.AddSingleton<QuartzJobRunner>();
|
||||||
|
services.AddSingleton<IJobFactory, IoCJobFactory>();
|
||||||
services.AddTransient<IBackgroundJobClient, BackgroundJobClient>();
|
services.AddTransient<IBackgroundJobClient, BackgroundJobClient>();
|
||||||
|
|
||||||
services.AddTransient<IPlexContentSync, PlexContentSync>();
|
services.AddTransient<IPlexContentSync, PlexContentSync>();
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
namespace Ombi.Schedule
|
namespace Ombi.Helpers
|
||||||
{
|
{
|
||||||
public class JobDataKeys
|
public class JobDataKeys
|
||||||
{
|
{
|
||||||
public const string RecentlyAddedSearch = "recentlyAddedSearch";
|
public const string RecentlyAddedSearch = "recentlyAddedSearch";
|
||||||
|
public const string NotificationOptions = nameof(NotificationOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,6 +14,7 @@
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||||
<PackageReference Include="Nito.AsyncEx" Version="5.0.0-pre-05" />
|
<PackageReference Include="Nito.AsyncEx" Version="5.0.0-pre-05" />
|
||||||
|
<PackageReference Include="Quartz" Version="3.0.7" />
|
||||||
<PackageReference Include="System.Security.Claims" Version="4.3.0" />
|
<PackageReference Include="System.Security.Claims" Version="4.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Ombi.Helpers;
|
|
||||||
using Quartz;
|
using Quartz;
|
||||||
using Quartz.Impl;
|
using Quartz.Impl;
|
||||||
using Quartz.Spi;
|
using Quartz.Spi;
|
||||||
|
|
||||||
namespace Ombi.Schedule
|
namespace Ombi.Helpers
|
||||||
{
|
{
|
||||||
public class OmbiQuartz
|
public class OmbiQuartz
|
||||||
{
|
{
|
||||||
|
@ -78,7 +77,12 @@ namespace Ombi.Schedule
|
||||||
{
|
{
|
||||||
await Scheduler.TriggerJob(new JobKey(jobName, group));
|
await Scheduler.TriggerJob(new JobKey(jobName, group));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task TriggerJob(string jobName, string group, IDictionary<string, object> data)
|
||||||
|
{
|
||||||
|
await Scheduler.TriggerJob(new JobKey(jobName, group), new JobDataMap(data));
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task Start()
|
public static async Task Start()
|
||||||
{
|
{
|
||||||
await Scheduler.Start();
|
await Scheduler.Start();
|
|
@ -1,13 +1,12 @@
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Ombi.Notifications;
|
using Ombi.Notifications;
|
||||||
using Ombi.Notifications.Models;
|
using Ombi.Notifications.Models;
|
||||||
|
using Quartz;
|
||||||
|
|
||||||
namespace Ombi.Core.Notifications
|
namespace Ombi.Core.Notifications
|
||||||
{
|
{
|
||||||
public interface INotificationService
|
public interface INotificationService : IJob
|
||||||
{
|
{
|
||||||
Task Publish(NotificationOptions model);
|
|
||||||
Task Publish(NotificationOptions model, Ombi.Settings.Settings.Models.Settings settings);
|
|
||||||
Task PublishTest(NotificationOptions model, Ombi.Settings.Settings.Models.Settings settings, INotification type);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,16 +7,56 @@ using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Core.Notifications;
|
using Ombi.Core.Notifications;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Notifications.Models;
|
using Ombi.Notifications.Models;
|
||||||
|
using Quartz;
|
||||||
|
|
||||||
namespace Ombi.Notifications
|
namespace Ombi.Notifications
|
||||||
{
|
{
|
||||||
public class NotificationService : INotificationService
|
public class NotificationService : INotificationService
|
||||||
{
|
{
|
||||||
|
private readonly IServiceProvider _provider;
|
||||||
|
|
||||||
public NotificationService(IServiceProvider provider, ILogger<NotificationService> log)
|
public NotificationService(IServiceProvider provider, ILogger<NotificationService> log)
|
||||||
{
|
{
|
||||||
|
_provider = provider;
|
||||||
Log = log;
|
Log = log;
|
||||||
NotificationAgents = new List<INotification>();
|
NotificationAgents = new List<INotification>();
|
||||||
|
PopulateAgents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<INotification> NotificationAgents { get; }
|
||||||
|
private ILogger<NotificationService> Log { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends a notification to the user. This one is used in normal notification scenarios
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context">The model.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task Execute(IJobExecutionContext context)
|
||||||
|
{
|
||||||
|
JobDataMap dataMap = context.MergedJobDataMap;
|
||||||
|
var model = (NotificationOptions)dataMap.Get(JobDataKeys.NotificationOptions);
|
||||||
|
|
||||||
|
foreach (var agent in NotificationAgents)
|
||||||
|
{
|
||||||
|
await NotifyAsync(agent, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task NotifyAsync(INotification notification, NotificationOptions model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await notification.NotifyAsync(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.LogError(LoggingEvents.Notification, ex, "Failed to notify for notification: {@notification}", notification);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PopulateAgents()
|
||||||
|
{
|
||||||
var baseSearchType = typeof(BaseNotification<>).Name;
|
var baseSearchType = typeof(BaseNotification<>).Name;
|
||||||
|
|
||||||
var ass = typeof(NotificationService).GetTypeInfo().Assembly;
|
var ass = typeof(NotificationService).GetTypeInfo().Assembly;
|
||||||
|
@ -32,7 +72,7 @@ namespace Ombi.Notifications
|
||||||
var services = new List<object>();
|
var services = new List<object>();
|
||||||
foreach (var param in ctor.GetParameters())
|
foreach (var param in ctor.GetParameters())
|
||||||
{
|
{
|
||||||
services.Add(provider.GetService(param.ParameterType));
|
services.Add(_provider.GetService(param.ParameterType));
|
||||||
}
|
}
|
||||||
|
|
||||||
var item = Activator.CreateInstance(type, services.ToArray());
|
var item = Activator.CreateInstance(type, services.ToArray());
|
||||||
|
@ -40,72 +80,5 @@ namespace Ombi.Notifications
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<INotification> NotificationAgents { get; }
|
|
||||||
private ILogger<NotificationService> Log { get; }
|
|
||||||
|
|
||||||
/// <summary>^
|
|
||||||
/// Sends a notification to the user. This one is used in normal notification scenarios
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model">The model.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task Publish(NotificationOptions model)
|
|
||||||
{
|
|
||||||
var notificationTasks = new List<Task>();
|
|
||||||
|
|
||||||
foreach (var agent in NotificationAgents)
|
|
||||||
{
|
|
||||||
notificationTasks.Add(NotifyAsync(agent,model));
|
|
||||||
}
|
|
||||||
await Task.WhenAll(notificationTasks).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sends a notification to the user, this is usually for testing the settings.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model">The model.</param>
|
|
||||||
/// <param name="settings">The settings.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task Publish(NotificationOptions model, Settings.Settings.Models.Settings settings)
|
|
||||||
{
|
|
||||||
var notificationTasks = NotificationAgents.Select(notification => NotifyAsync(notification, model, settings));
|
|
||||||
|
|
||||||
await Task.WhenAll(notificationTasks).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task NotifyAsync(INotification notification, NotificationOptions model)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await notification.NotifyAsync(model).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.LogError(LoggingEvents.Notification, ex, "Failed to notify for notification: {@notification}", notification);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task NotifyAsync(INotification notification, NotificationOptions model, Ombi.Settings.Settings.Models.Settings settings)
|
|
||||||
{
|
|
||||||
if (model.RequestId == 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("RequestId is not set");
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await notification.NotifyAsync(model, settings).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException(ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task PublishTest(NotificationOptions model, Ombi.Settings.Settings.Models.Settings settings, INotification type)
|
|
||||||
{
|
|
||||||
await type.NotifyAsync(model, settings);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,26 +7,18 @@ namespace Ombi.Schedule
|
||||||
{
|
{
|
||||||
public class IoCJobFactory : IJobFactory
|
public class IoCJobFactory : IJobFactory
|
||||||
{
|
{
|
||||||
private readonly IServiceProvider _factory;
|
private readonly IServiceProvider _serviceProvider;
|
||||||
|
public IoCJobFactory(IServiceProvider serviceProvider)
|
||||||
public IoCJobFactory(IServiceProvider factory)
|
|
||||||
{
|
{
|
||||||
_factory = factory;
|
_serviceProvider = serviceProvider;
|
||||||
}
|
}
|
||||||
public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
|
public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
|
||||||
{
|
{
|
||||||
var scopeFactory = _factory.GetService<IServiceScopeFactory>();
|
return _serviceProvider.GetRequiredService<QuartzJobRunner>();
|
||||||
var scope = scopeFactory.CreateScope();
|
|
||||||
var scopedContainer = scope.ServiceProvider;
|
|
||||||
|
|
||||||
var implementation = scopedContainer.GetRequiredService(bundle.JobDetail.JobType) as IJob;
|
|
||||||
return implementation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReturnJob(IJob job)
|
public void ReturnJob(IJob job)
|
||||||
{
|
{
|
||||||
var disposable = job as IDisposable;
|
|
||||||
disposable?.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,6 +31,7 @@ using System.Threading.Tasks;
|
||||||
using Hangfire;
|
using Hangfire;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Ombi.Core;
|
||||||
using Ombi.Core.Notifications;
|
using Ombi.Core.Notifications;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Notifications.Models;
|
using Ombi.Notifications.Models;
|
||||||
|
@ -45,7 +46,7 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
public class EmbyAvaliabilityChecker : IEmbyAvaliabilityChecker
|
public class EmbyAvaliabilityChecker : IEmbyAvaliabilityChecker
|
||||||
{
|
{
|
||||||
public EmbyAvaliabilityChecker(IEmbyContentRepository repo, ITvRequestRepository t, IMovieRequestRepository m,
|
public EmbyAvaliabilityChecker(IEmbyContentRepository repo, ITvRequestRepository t, IMovieRequestRepository m,
|
||||||
INotificationService n, ILogger<EmbyAvaliabilityChecker> log)
|
INotificationHelper n, ILogger<EmbyAvaliabilityChecker> log)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_tvRepo = t;
|
_tvRepo = t;
|
||||||
|
@ -57,7 +58,7 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
private readonly ITvRequestRepository _tvRepo;
|
private readonly ITvRequestRepository _tvRepo;
|
||||||
private readonly IMovieRequestRepository _movieRepo;
|
private readonly IMovieRequestRepository _movieRepo;
|
||||||
private readonly IEmbyContentRepository _repo;
|
private readonly IEmbyContentRepository _repo;
|
||||||
private readonly INotificationService _notificationService;
|
private readonly INotificationHelper _notificationService;
|
||||||
private readonly ILogger<EmbyAvaliabilityChecker> _log;
|
private readonly ILogger<EmbyAvaliabilityChecker> _log;
|
||||||
|
|
||||||
public async Task Execute(IJobExecutionContext job)
|
public async Task Execute(IJobExecutionContext job)
|
||||||
|
@ -100,14 +101,14 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
|
|
||||||
_log.LogDebug("MovieId: {0}, RequestUser: {1}", movie.Id, recipient);
|
_log.LogDebug("MovieId: {0}, RequestUser: {1}", movie.Id, recipient);
|
||||||
|
|
||||||
BackgroundJob.Enqueue(() => _notificationService.Publish(new NotificationOptions
|
await _notificationService.Notify(new NotificationOptions
|
||||||
{
|
{
|
||||||
DateTime = DateTime.Now,
|
DateTime = DateTime.Now,
|
||||||
NotificationType = NotificationType.RequestAvailable,
|
NotificationType = NotificationType.RequestAvailable,
|
||||||
RequestId = movie.Id,
|
RequestId = movie.Id,
|
||||||
RequestType = RequestType.Movie,
|
RequestType = RequestType.Movie,
|
||||||
Recipient = recipient,
|
Recipient = recipient,
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await _movieRepo.Save();
|
await _movieRepo.Save();
|
||||||
|
@ -191,14 +192,14 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
// We have fulfulled this request!
|
// We have fulfulled this request!
|
||||||
child.Available = true;
|
child.Available = true;
|
||||||
child.MarkedAsAvailable = DateTime.Now;
|
child.MarkedAsAvailable = DateTime.Now;
|
||||||
BackgroundJob.Enqueue(() => _notificationService.Publish(new NotificationOptions
|
await _notificationService.Notify(new NotificationOptions
|
||||||
{
|
{
|
||||||
DateTime = DateTime.Now,
|
DateTime = DateTime.Now,
|
||||||
NotificationType = NotificationType.RequestAvailable,
|
NotificationType = NotificationType.RequestAvailable,
|
||||||
RequestId = child.Id,
|
RequestId = child.Id,
|
||||||
RequestType = RequestType.TvShow,
|
RequestType = RequestType.TvShow,
|
||||||
Recipient = child.RequestedUser.Email
|
Recipient = child.RequestedUser.Email
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Api.Emby;
|
using Ombi.Api.Emby;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
using Ombi.Core.Settings.Models.External;
|
using Ombi.Core.Settings.Models.External;
|
||||||
|
using Ombi.Helpers;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using Ombi.Store.Repository;
|
using Ombi.Store.Repository;
|
||||||
using Quartz;
|
using Quartz;
|
||||||
|
|
|
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||||
using Hangfire;
|
using Hangfire;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Ombi.Core;
|
||||||
using Ombi.Core.Notifications;
|
using Ombi.Core.Notifications;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Notifications.Models;
|
using Ombi.Notifications.Models;
|
||||||
|
@ -18,7 +19,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
public class LidarrAvailabilityChecker : ILidarrAvailabilityChecker
|
public class LidarrAvailabilityChecker : ILidarrAvailabilityChecker
|
||||||
{
|
{
|
||||||
public LidarrAvailabilityChecker(IMusicRequestRepository requests, IRepository<LidarrAlbumCache> albums, ILogger<LidarrAvailabilityChecker> log,
|
public LidarrAvailabilityChecker(IMusicRequestRepository requests, IRepository<LidarrAlbumCache> albums, ILogger<LidarrAvailabilityChecker> log,
|
||||||
IBackgroundJobClient job, INotificationService notification)
|
IBackgroundJobClient job, INotificationHelper notification)
|
||||||
{
|
{
|
||||||
_cachedAlbums = albums;
|
_cachedAlbums = albums;
|
||||||
_requestRepository = requests;
|
_requestRepository = requests;
|
||||||
|
@ -31,7 +32,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
private readonly IRepository<LidarrAlbumCache> _cachedAlbums;
|
private readonly IRepository<LidarrAlbumCache> _cachedAlbums;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IBackgroundJobClient _job;
|
private readonly IBackgroundJobClient _job;
|
||||||
private readonly INotificationService _notificationService;
|
private readonly INotificationHelper _notificationService;
|
||||||
|
|
||||||
public async Task Start()
|
public async Task Start()
|
||||||
{
|
{
|
||||||
|
@ -59,14 +60,15 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
|
|
||||||
_logger.LogDebug("AlbumId: {0}, RequestUser: {1}", albumRequest.Id, recipient);
|
_logger.LogDebug("AlbumId: {0}, RequestUser: {1}", albumRequest.Id, recipient);
|
||||||
|
|
||||||
_job.Enqueue(() => _notificationService.Publish(new NotificationOptions
|
|
||||||
|
await _notificationService.Notify(new NotificationOptions
|
||||||
{
|
{
|
||||||
DateTime = DateTime.Now,
|
DateTime = DateTime.Now,
|
||||||
NotificationType = NotificationType.RequestAvailable,
|
NotificationType = NotificationType.RequestAvailable,
|
||||||
RequestId = albumRequest.Id,
|
RequestId = albumRequest.Id,
|
||||||
RequestType = RequestType.Album,
|
RequestType = RequestType.Album,
|
||||||
Recipient = recipient,
|
Recipient = recipient,
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||||
using Hangfire;
|
using Hangfire;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Ombi.Core;
|
||||||
using Ombi.Core.Notifications;
|
using Ombi.Core.Notifications;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Notifications.Models;
|
using Ombi.Notifications.Models;
|
||||||
|
@ -19,7 +20,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
public class PlexAvailabilityChecker : IPlexAvailabilityChecker
|
public class PlexAvailabilityChecker : IPlexAvailabilityChecker
|
||||||
{
|
{
|
||||||
public PlexAvailabilityChecker(IPlexContentRepository repo, ITvRequestRepository tvRequest, IMovieRequestRepository movies,
|
public PlexAvailabilityChecker(IPlexContentRepository repo, ITvRequestRepository tvRequest, IMovieRequestRepository movies,
|
||||||
INotificationService notification, IBackgroundJobClient background, ILogger<PlexAvailabilityChecker> log)
|
INotificationHelper notification, IBackgroundJobClient background, ILogger<PlexAvailabilityChecker> log)
|
||||||
{
|
{
|
||||||
_tvRepo = tvRequest;
|
_tvRepo = tvRequest;
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
|
@ -32,7 +33,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
private readonly ITvRequestRepository _tvRepo;
|
private readonly ITvRequestRepository _tvRepo;
|
||||||
private readonly IMovieRequestRepository _movieRepo;
|
private readonly IMovieRequestRepository _movieRepo;
|
||||||
private readonly IPlexContentRepository _repo;
|
private readonly IPlexContentRepository _repo;
|
||||||
private readonly INotificationService _notificationService;
|
private readonly INotificationHelper _notificationService;
|
||||||
private readonly IBackgroundJobClient _backgroundJobClient;
|
private readonly IBackgroundJobClient _backgroundJobClient;
|
||||||
private readonly ILogger _log;
|
private readonly ILogger _log;
|
||||||
|
|
||||||
|
@ -126,7 +127,8 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
// We have ful-fulled this request!
|
// We have ful-fulled this request!
|
||||||
child.Available = true;
|
child.Available = true;
|
||||||
child.MarkedAsAvailable = DateTime.Now;
|
child.MarkedAsAvailable = DateTime.Now;
|
||||||
await _notificationService.Publish(new NotificationOptions
|
|
||||||
|
await _notificationService.Notify(new NotificationOptions
|
||||||
{
|
{
|
||||||
DateTime = DateTime.Now,
|
DateTime = DateTime.Now,
|
||||||
NotificationType = NotificationType.RequestAvailable,
|
NotificationType = NotificationType.RequestAvailable,
|
||||||
|
@ -170,7 +172,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
item.RequestId = movie.Id;
|
item.RequestId = movie.Id;
|
||||||
|
|
||||||
_log.LogInformation("[PAC] - Movie request {0} is now available, sending notification", $"{movie.Title} - {movie.Id}");
|
_log.LogInformation("[PAC] - Movie request {0} is now available, sending notification", $"{movie.Title} - {movie.Id}");
|
||||||
await _notificationService.Publish(new NotificationOptions
|
await _notificationService.Notify(new NotificationOptions
|
||||||
{
|
{
|
||||||
DateTime = DateTime.Now,
|
DateTime = DateTime.Now,
|
||||||
NotificationType = NotificationType.RequestAvailable,
|
NotificationType = NotificationType.RequestAvailable,
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Ombi.Core.Notifications;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
|
using Ombi.Helpers;
|
||||||
using Ombi.Schedule.Jobs;
|
using Ombi.Schedule.Jobs;
|
||||||
using Ombi.Schedule.Jobs.Couchpotato;
|
using Ombi.Schedule.Jobs.Couchpotato;
|
||||||
using Ombi.Schedule.Jobs.Emby;
|
using Ombi.Schedule.Jobs.Emby;
|
||||||
|
@ -53,6 +55,7 @@ namespace Ombi.Schedule
|
||||||
await AddEmby(s);
|
await AddEmby(s);
|
||||||
await AddDvrApps(s);
|
await AddDvrApps(s);
|
||||||
await AddSystem(s);
|
await AddSystem(s);
|
||||||
|
await AddNotifications(s);
|
||||||
|
|
||||||
// Run Quartz
|
// Run Quartz
|
||||||
await OmbiQuartz.Start();
|
await OmbiQuartz.Start();
|
||||||
|
@ -93,5 +96,9 @@ namespace Ombi.Schedule
|
||||||
await OmbiQuartz.Instance.AddJob<IEmbyAvaliabilityChecker>(nameof(IEmbyAvaliabilityChecker), "Emby", null);
|
await OmbiQuartz.Instance.AddJob<IEmbyAvaliabilityChecker>(nameof(IEmbyAvaliabilityChecker), "Emby", null);
|
||||||
await OmbiQuartz.Instance.AddJob<IEmbyUserImporter>(nameof(IEmbyUserImporter), "Emby", JobSettingsHelper.UserImporter(s));
|
await OmbiQuartz.Instance.AddJob<IEmbyUserImporter>(nameof(IEmbyUserImporter), "Emby", JobSettingsHelper.UserImporter(s));
|
||||||
}
|
}
|
||||||
|
private static async Task AddNotifications(JobSettings s)
|
||||||
|
{
|
||||||
|
await OmbiQuartz.Instance.AddJob<INotificationService>(nameof(INotificationService), "Notifications", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
27
src/Ombi.Schedule/QuartzJobRunner.cs
Normal file
27
src/Ombi.Schedule/QuartzJobRunner.cs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Quartz;
|
||||||
|
|
||||||
|
namespace Ombi.Schedule
|
||||||
|
{
|
||||||
|
public class QuartzJobRunner : IJob
|
||||||
|
{
|
||||||
|
private readonly IServiceProvider _serviceProvider;
|
||||||
|
public QuartzJobRunner(IServiceProvider serviceProvider)
|
||||||
|
{
|
||||||
|
_serviceProvider = serviceProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Execute(IJobExecutionContext context)
|
||||||
|
{
|
||||||
|
using (var scope = _serviceProvider.CreateScope())
|
||||||
|
{
|
||||||
|
var jobType = context.JobDetail.JobType;
|
||||||
|
var job = scope.ServiceProvider.GetRequiredService(jobType) as IJob;
|
||||||
|
|
||||||
|
await job.Execute(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,7 +27,7 @@ namespace Ombi.Controllers
|
||||||
public class IssuesController : ControllerBase
|
public class IssuesController : ControllerBase
|
||||||
{
|
{
|
||||||
public IssuesController(IRepository<IssueCategory> categories, IRepository<Issues> issues, IRepository<IssueComments> comments,
|
public IssuesController(IRepository<IssueCategory> categories, IRepository<Issues> issues, IRepository<IssueComments> comments,
|
||||||
UserManager<OmbiUser> userManager, INotificationService notify)
|
UserManager<OmbiUser> userManager, INotificationHelper notify)
|
||||||
{
|
{
|
||||||
_categories = categories;
|
_categories = categories;
|
||||||
_issues = issues;
|
_issues = issues;
|
||||||
|
@ -40,7 +40,7 @@ namespace Ombi.Controllers
|
||||||
private readonly IRepository<Issues> _issues;
|
private readonly IRepository<Issues> _issues;
|
||||||
private readonly IRepository<IssueComments> _issueComments;
|
private readonly IRepository<IssueComments> _issueComments;
|
||||||
private readonly UserManager<OmbiUser> _userManager;
|
private readonly UserManager<OmbiUser> _userManager;
|
||||||
private readonly INotificationService _notification;
|
private readonly INotificationHelper _notification;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get's all categories
|
/// Get's all categories
|
||||||
|
@ -152,7 +152,7 @@ namespace Ombi.Controllers
|
||||||
|
|
||||||
AddIssueNotificationSubstitutes(notificationModel, i, User.Identity.Name);
|
AddIssueNotificationSubstitutes(notificationModel, i, User.Identity.Name);
|
||||||
|
|
||||||
BackgroundJob.Enqueue(() => _notification.Publish(notificationModel));
|
await _notification.Notify(notificationModel);
|
||||||
|
|
||||||
return i.Id;
|
return i.Id;
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ namespace Ombi.Controllers
|
||||||
notificationModel.Recipient = user.Email;
|
notificationModel.Recipient = user.Email;
|
||||||
}
|
}
|
||||||
|
|
||||||
BackgroundJob.Enqueue(() => _notification.Publish(notificationModel));
|
await _notification.Notify(notificationModel);
|
||||||
|
|
||||||
return await _issueComments.Add(newComment);
|
return await _issueComments.Add(newComment);
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ namespace Ombi.Controllers
|
||||||
};
|
};
|
||||||
AddIssueNotificationSubstitutes(notificationModel, issue, issue.UserReported?.UserAlias ?? string.Empty);
|
AddIssueNotificationSubstitutes(notificationModel, issue, issue.UserReported?.UserAlias ?? string.Empty);
|
||||||
|
|
||||||
BackgroundJob.Enqueue(() => _notification.Publish(notificationModel));
|
await _notification.Notify(notificationModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue