Skip to content

Commit b492699

Browse files
committed
fix(availability): Fixed an issue where we wouldn't mark a available 4k movie as available (when 4K request feature is disabled)
1 parent 0b0ed49 commit b492699

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
using Microsoft.EntityFrameworkCore;
77
using Microsoft.Extensions.Logging;
88
using Ombi.Core;
9+
using Ombi.Core.Services;
910
using Ombi.Helpers;
1011
using Ombi.Hubs;
1112
using Ombi.Notifications.Models;
1213
using Ombi.Schedule.Jobs.Plex.Models;
14+
using Ombi.Settings.Settings.Models;
1315
using Ombi.Store.Entities;
1416
using Ombi.Store.Entities.Requests;
1517
using Ombi.Store.Repository;
@@ -21,14 +23,15 @@ namespace Ombi.Schedule.Jobs.Plex
2123
public class PlexAvailabilityChecker : IPlexAvailabilityChecker
2224
{
2325
public PlexAvailabilityChecker(IPlexContentRepository repo, ITvRequestRepository tvRequest, IMovieRequestRepository movies,
24-
INotificationHelper notification, ILogger<PlexAvailabilityChecker> log, IHubContext<NotificationHub> hub)
26+
INotificationHelper notification, ILogger<PlexAvailabilityChecker> log, IHubContext<NotificationHub> hub, IFeatureService featureService)
2527
{
2628
_tvRepo = tvRequest;
2729
_repo = repo;
2830
_movieRepo = movies;
2931
_notificationService = notification;
3032
_log = log;
3133
_notification = hub;
34+
_featureService = featureService;
3235
}
3336

3437
private readonly ITvRequestRepository _tvRepo;
@@ -37,6 +40,7 @@ public PlexAvailabilityChecker(IPlexContentRepository repo, ITvRequestRepository
3740
private readonly INotificationHelper _notificationService;
3841
private readonly ILogger _log;
3942
private readonly IHubContext<NotificationHub> _notification;
43+
private readonly IFeatureService _featureService;
4044

4145
public async Task Execute(IJobExecutionContext job)
4246
{
@@ -179,6 +183,7 @@ await _notificationService.Notify(new NotificationOptions
179183

180184
private async Task ProcessMovies()
181185
{
186+
var feature4kEnabled = await _featureService.FeatureEnabled(FeatureNames.Movie4KRequests);
182187
// Get all non available
183188
var movies = _movieRepo.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available || (!x.Available4K && x.Has4KRequest));
184189
var itemsForAvailbility = new List<AvailabilityModel>();
@@ -208,7 +213,7 @@ private async Task ProcessMovies()
208213

209214
var notify = false;
210215

211-
if (has4kRequest && item.Has4K && !movie.Available4K)
216+
if (has4kRequest && item.Has4K && !movie.Available4K && feature4kEnabled)
212217
{
213218
movie.Available4K = true;
214219
movie.Approved4K = true;
@@ -217,6 +222,14 @@ private async Task ProcessMovies()
217222
notify = true;
218223
}
219224

225+
if (!feature4kEnabled && !movie.Available)
226+
{
227+
movie.Available = true;
228+
movie.MarkedAsAvailable = DateTime.Now;
229+
await _movieRepo.SaveChangesAsync();
230+
notify = true;
231+
}
232+
220233
// If we have a non-4k versison then mark as available
221234
if (item.Quality != null && !movie.Available)
222235
{

0 commit comments

Comments
 (0)