mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 10:36:54 -07:00
Make sure it's enabled before sending the recently added
This commit is contained in:
parent
087d825665
commit
7597202aac
1 changed files with 10 additions and 3 deletions
|
@ -48,13 +48,14 @@ namespace PlexRequests.Services.Jobs
|
|||
public class RecentlyAdded : IJob, IRecentlyAdded
|
||||
{
|
||||
public RecentlyAdded(IPlexApi api, ISettingsService<PlexSettings> plexSettings, ISettingsService<EmailNotificationSettings> email,
|
||||
ISettingsService<ScheduledJobsSettings> scheduledService, IJobRecord rec)
|
||||
ISettingsService<ScheduledJobsSettings> scheduledService, IJobRecord rec, ISettingsService<PlexRequestSettings> plexRequest)
|
||||
{
|
||||
JobRecord = rec;
|
||||
Api = api;
|
||||
PlexSettings = plexSettings;
|
||||
EmailSettings = email;
|
||||
ScheduledJobsSettings = scheduledService;
|
||||
PlexRequestSettings = plexRequest;
|
||||
}
|
||||
|
||||
private IPlexApi Api { get; }
|
||||
|
@ -62,6 +63,7 @@ namespace PlexRequests.Services.Jobs
|
|||
private readonly TheMovieDbApi _movieApi = new TheMovieDbApi();
|
||||
private ISettingsService<PlexSettings> PlexSettings { get; }
|
||||
private ISettingsService<EmailNotificationSettings> EmailSettings { get; }
|
||||
private ISettingsService<PlexRequestSettings> PlexRequestSettings { get; }
|
||||
private ISettingsService<ScheduledJobsSettings> ScheduledJobsSettings { get; }
|
||||
private IJobRecord JobRecord { get; }
|
||||
|
||||
|
@ -71,14 +73,19 @@ namespace PlexRequests.Services.Jobs
|
|||
{
|
||||
try
|
||||
{
|
||||
var settings = PlexRequestSettings.GetSettings();
|
||||
if (!settings.SendRecentlyAddedEmail)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var jobs = JobRecord.GetJobs();
|
||||
var thisJob =
|
||||
jobs.FirstOrDefault(
|
||||
x => x.Name.Equals(JobNames.RecentlyAddedEmail, StringComparison.CurrentCultureIgnoreCase));
|
||||
|
||||
var settings = ScheduledJobsSettings.GetSettings();
|
||||
var jobSettings = ScheduledJobsSettings.GetSettings();
|
||||
|
||||
if (thisJob?.LastRun > DateTime.Now.AddHours(-settings.RecentlyAdded))
|
||||
if (thisJob?.LastRun > DateTime.Now.AddHours(-jobSettings.RecentlyAdded))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue