mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Removed hangfire completly from Ombi
This commit is contained in:
parent
181bd53202
commit
b41fcb467e
25 changed files with 15 additions and 130 deletions
|
@ -11,7 +11,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoMapper" Version="6.1.1" />
|
<PackageReference Include="AutoMapper" Version="6.1.1" />
|
||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="3.2.0" />
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="3.2.0" />
|
||||||
<PackageReference Include="Hangfire" Version="1.6.22" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.2" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.2" />
|
||||||
<PackageReference Include="MiniProfiler.AspNetCore" Version="4.0.0-alpha6-79" />
|
<PackageReference Include="MiniProfiler.AspNetCore" Version="4.0.0-alpha6-79" />
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
@ -183,7 +182,6 @@ namespace Ombi.DependencyInjection
|
||||||
{
|
{
|
||||||
services.AddSingleton<QuartzJobRunner>();
|
services.AddSingleton<QuartzJobRunner>();
|
||||||
services.AddSingleton<IJobFactory, IoCJobFactory>();
|
services.AddSingleton<IJobFactory, IoCJobFactory>();
|
||||||
services.AddTransient<IBackgroundJobClient, BackgroundJobClient>();
|
|
||||||
|
|
||||||
services.AddTransient<IPlexContentSync, PlexContentSync>();
|
services.AddTransient<IPlexContentSync, PlexContentSync>();
|
||||||
services.AddTransient<IEmbyContentSync, EmbyContentSync>();
|
services.AddTransient<IEmbyContentSync, EmbyContentSync>();
|
||||||
|
|
|
@ -3,6 +3,7 @@ using NUnit.Framework;
|
||||||
using Quartz;
|
using Quartz;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Ombi.Helpers;
|
||||||
|
|
||||||
namespace Ombi.Schedule.Tests
|
namespace Ombi.Schedule.Tests
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,9 +4,9 @@ using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Castle.Components.DictionaryAdapter;
|
using Castle.Components.DictionaryAdapter;
|
||||||
using Hangfire;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using Ombi.Core;
|
||||||
using Ombi.Core.Notifications;
|
using Ombi.Core.Notifications;
|
||||||
using Ombi.Schedule.Jobs.Plex;
|
using Ombi.Schedule.Jobs.Plex;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
|
@ -25,15 +25,15 @@ namespace Ombi.Schedule.Tests
|
||||||
_repo = new Mock<IPlexContentRepository>();
|
_repo = new Mock<IPlexContentRepository>();
|
||||||
_tv = new Mock<ITvRequestRepository>();
|
_tv = new Mock<ITvRequestRepository>();
|
||||||
_movie = new Mock<IMovieRequestRepository>();
|
_movie = new Mock<IMovieRequestRepository>();
|
||||||
_notify = new Mock<INotificationService>();
|
_notify = new Mock<INotificationHelper>();
|
||||||
Checker = new PlexAvailabilityChecker(_repo.Object, _tv.Object, _movie.Object, _notify.Object, new Mock<IBackgroundJobClient>().Object, null);
|
Checker = new PlexAvailabilityChecker(_repo.Object, _tv.Object, _movie.Object, _notify.Object, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Mock<IPlexContentRepository> _repo;
|
private Mock<IPlexContentRepository> _repo;
|
||||||
private Mock<ITvRequestRepository> _tv;
|
private Mock<ITvRequestRepository> _tv;
|
||||||
private Mock<IMovieRequestRepository> _movie;
|
private Mock<IMovieRequestRepository> _movie;
|
||||||
private Mock<INotificationService> _notify;
|
private Mock<INotificationHelper> _notify;
|
||||||
private PlexAvailabilityChecker Checker;
|
private PlexAvailabilityChecker Checker;
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
namespace Ombi.Schedule
|
|
||||||
{
|
|
||||||
public class IoCJobActivator : JobActivator
|
|
||||||
{
|
|
||||||
private readonly IServiceProvider _container;
|
|
||||||
public IoCJobActivator(IServiceProvider container)
|
|
||||||
{
|
|
||||||
_container = container;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override object ActivateJob(Type type)
|
|
||||||
{
|
|
||||||
var scopeFactory = _container.GetService<IServiceScopeFactory>();
|
|
||||||
var scope = scopeFactory.CreateScope();
|
|
||||||
var scopedContainer = scope.ServiceProvider;
|
|
||||||
|
|
||||||
var interfaceType = type.GetTypeInfo().ImplementedInterfaces.FirstOrDefault();
|
|
||||||
var implementation = scopedContainer.GetRequiredService(interfaceType);
|
|
||||||
return implementation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -28,11 +28,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Core;
|
using Ombi.Core;
|
||||||
using Ombi.Core.Notifications;
|
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Notifications.Models;
|
using Ombi.Notifications.Models;
|
||||||
using Ombi.Schedule.Jobs.Ombi;
|
using Ombi.Schedule.Jobs.Ombi;
|
||||||
|
|
|
@ -2,18 +2,15 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Api.Emby;
|
using Ombi.Api.Emby;
|
||||||
using Ombi.Api.Emby.Models.Movie;
|
using Ombi.Api.Emby.Models.Movie;
|
||||||
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.Helpers;
|
||||||
using Ombi.Schedule.Jobs.Ombi;
|
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using Ombi.Store.Repository;
|
using Ombi.Store.Repository;
|
||||||
using Quartz;
|
using Quartz;
|
||||||
using Serilog;
|
|
||||||
using EmbyMediaType = Ombi.Store.Entities.EmbyMediaType;
|
using EmbyMediaType = Ombi.Store.Entities.EmbyMediaType;
|
||||||
|
|
||||||
namespace Ombi.Schedule.Jobs.Emby
|
namespace Ombi.Schedule.Jobs.Emby
|
||||||
|
|
|
@ -29,7 +29,6 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Api.Emby;
|
using Ombi.Api.Emby;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Internal;
|
using Microsoft.EntityFrameworkCore.Internal;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
@ -18,13 +17,12 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
public class LidarrAlbumSync : ILidarrAlbumSync
|
public class LidarrAlbumSync : ILidarrAlbumSync
|
||||||
{
|
{
|
||||||
public LidarrAlbumSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrAlbumSync> log, ExternalContext ctx,
|
public LidarrAlbumSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrAlbumSync> log, ExternalContext ctx,
|
||||||
IBackgroundJobClient job, ILidarrAvailabilityChecker availability)
|
ILidarrAvailabilityChecker availability)
|
||||||
{
|
{
|
||||||
_lidarrSettings = lidarr;
|
_lidarrSettings = lidarr;
|
||||||
_lidarrApi = lidarrApi;
|
_lidarrApi = lidarrApi;
|
||||||
_logger = log;
|
_logger = log;
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
_job = job;
|
|
||||||
_availability = availability;
|
_availability = availability;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +30,6 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
private readonly ILidarrApi _lidarrApi;
|
private readonly ILidarrApi _lidarrApi;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ExternalContext _ctx;
|
private readonly ExternalContext _ctx;
|
||||||
private readonly IBackgroundJobClient _job;
|
|
||||||
private readonly ILidarrAvailabilityChecker _availability;
|
private readonly ILidarrAvailabilityChecker _availability;
|
||||||
|
|
||||||
public async Task CacheContent()
|
public async Task CacheContent()
|
||||||
|
@ -87,7 +84,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
_logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Lidarr Album");
|
_logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Lidarr Album");
|
||||||
}
|
}
|
||||||
|
|
||||||
_job.Enqueue(() => _availability.Start());
|
await _availability.Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Internal;
|
using Microsoft.EntityFrameworkCore.Internal;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
@ -19,13 +18,12 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
public class LidarrArtistSync : ILidarrArtistSync
|
public class LidarrArtistSync : ILidarrArtistSync
|
||||||
{
|
{
|
||||||
public LidarrArtistSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrArtistSync> log, ExternalContext ctx,
|
public LidarrArtistSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrArtistSync> log, ExternalContext ctx,
|
||||||
IBackgroundJobClient background, ILidarrAlbumSync album)
|
ILidarrAlbumSync album)
|
||||||
{
|
{
|
||||||
_lidarrSettings = lidarr;
|
_lidarrSettings = lidarr;
|
||||||
_lidarrApi = lidarrApi;
|
_lidarrApi = lidarrApi;
|
||||||
_logger = log;
|
_logger = log;
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
_job = background;
|
|
||||||
_albumSync = album;
|
_albumSync = album;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +31,6 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
private readonly ILidarrApi _lidarrApi;
|
private readonly ILidarrApi _lidarrApi;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ExternalContext _ctx;
|
private readonly ExternalContext _ctx;
|
||||||
private readonly IBackgroundJobClient _job;
|
|
||||||
private readonly ILidarrAlbumSync _albumSync;
|
private readonly ILidarrAlbumSync _albumSync;
|
||||||
|
|
||||||
public async Task Execute(IJobExecutionContext job)
|
public async Task Execute(IJobExecutionContext job)
|
||||||
|
@ -84,7 +81,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
_logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Lidarr");
|
_logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Lidarr");
|
||||||
}
|
}
|
||||||
|
|
||||||
_job.Enqueue(() => _albumSync.CacheContent());
|
await _albumSync.CacheContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
|
|
@ -2,11 +2,9 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Core;
|
using Ombi.Core;
|
||||||
using Ombi.Core.Notifications;
|
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Notifications.Models;
|
using Ombi.Notifications.Models;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
|
@ -18,20 +16,17 @@ 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, INotificationHelper notification)
|
||||||
IBackgroundJobClient job, INotificationHelper notification)
|
|
||||||
{
|
{
|
||||||
_cachedAlbums = albums;
|
_cachedAlbums = albums;
|
||||||
_requestRepository = requests;
|
_requestRepository = requests;
|
||||||
_logger = log;
|
_logger = log;
|
||||||
_job = job;
|
|
||||||
_notificationService = notification;
|
_notificationService = notification;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IMusicRequestRepository _requestRepository;
|
private readonly IMusicRequestRepository _requestRepository;
|
||||||
private readonly IRepository<LidarrAlbumCache> _cachedAlbums;
|
private readonly IRepository<LidarrAlbumCache> _cachedAlbums;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IBackgroundJobClient _job;
|
|
||||||
private readonly INotificationHelper _notificationService;
|
private readonly INotificationHelper _notificationService;
|
||||||
|
|
||||||
public async Task Start()
|
public async Task Start()
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire.Server;
|
|
||||||
|
|
||||||
namespace Ombi.Schedule.Jobs.Ombi
|
namespace Ombi.Schedule.Jobs.Ombi
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Api.Plex;
|
|
||||||
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.Helpers;
|
||||||
|
|
|
@ -9,8 +9,6 @@ using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
|
||||||
using Hangfire.Server;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Core.Processor;
|
using Ombi.Core.Processor;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Api.Emby;
|
using Ombi.Api.Emby;
|
||||||
using Ombi.Api.TheMovieDb;
|
using Ombi.Api.TheMovieDb;
|
||||||
|
@ -11,8 +9,6 @@ using Ombi.Api.TvMaze;
|
||||||
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.Helpers;
|
||||||
using Ombi.Schedule.Jobs.Emby;
|
|
||||||
using Ombi.Schedule.Jobs.Plex;
|
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using Ombi.Store.Repository;
|
using Ombi.Store.Repository;
|
||||||
using Quartz;
|
using Quartz;
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Core;
|
using Ombi.Core;
|
||||||
using Ombi.Core.Notifications;
|
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Notifications.Models;
|
using Ombi.Notifications.Models;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
|
@ -20,13 +17,12 @@ 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,
|
||||||
INotificationHelper notification, IBackgroundJobClient background, ILogger<PlexAvailabilityChecker> log)
|
INotificationHelper notification, ILogger<PlexAvailabilityChecker> log)
|
||||||
{
|
{
|
||||||
_tvRepo = tvRequest;
|
_tvRepo = tvRequest;
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_movieRepo = movies;
|
_movieRepo = movies;
|
||||||
_notificationService = notification;
|
_notificationService = notification;
|
||||||
_backgroundJobClient = background;
|
|
||||||
_log = log;
|
_log = log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +30,6 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
private readonly IMovieRequestRepository _movieRepo;
|
private readonly IMovieRequestRepository _movieRepo;
|
||||||
private readonly IPlexContentRepository _repo;
|
private readonly IPlexContentRepository _repo;
|
||||||
private readonly INotificationHelper _notificationService;
|
private readonly INotificationHelper _notificationService;
|
||||||
private readonly IBackgroundJobClient _backgroundJobClient;
|
|
||||||
private readonly ILogger _log;
|
private readonly ILogger _log;
|
||||||
|
|
||||||
public async Task Execute(IJobExecutionContext job)
|
public async Task Execute(IJobExecutionContext job)
|
||||||
|
|
|
@ -29,7 +29,6 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Api.Plex;
|
using Ombi.Api.Plex;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Api.Plex;
|
using Ombi.Api.Plex;
|
||||||
|
|
|
@ -10,12 +10,6 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Dapper" Version="1.50.2" />
|
<PackageReference Include="Dapper" Version="1.50.2" />
|
||||||
<PackageReference Include="Hangfire" Version="1.6.22" />
|
|
||||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.6.22" />
|
|
||||||
<PackageReference Include="Hangfire.Console" Version="1.3.10" />
|
|
||||||
<PackageReference Include="Hangfire.MemoryStorage.Core" Version="1.4.0" />
|
|
||||||
<PackageReference Include="Hangfire.RecurringJobExtensions" Version="1.1.6" />
|
|
||||||
<PackageReference Include="Hangfire.SQLite" Version="1.4.2" />
|
|
||||||
<PackageReference Include="Serilog" Version="2.7.1" />
|
<PackageReference Include="Serilog" Version="2.7.1" />
|
||||||
<PackageReference Include="Quartz" Version="3.0.7" />
|
<PackageReference Include="Quartz" Version="3.0.7" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
@ -860,7 +859,7 @@ namespace Ombi.Controllers
|
||||||
|
|
||||||
[HttpPost("welcomeEmail")]
|
[HttpPost("welcomeEmail")]
|
||||||
[PowerUser]
|
[PowerUser]
|
||||||
public void SendWelcomeEmail([FromBody] UserViewModel user)
|
public async Task<IActionResult> SendWelcomeEmail([FromBody] UserViewModel user)
|
||||||
{
|
{
|
||||||
var ombiUser = new OmbiUser
|
var ombiUser = new OmbiUser
|
||||||
{
|
{
|
||||||
|
@ -868,7 +867,8 @@ namespace Ombi.Controllers
|
||||||
Email = user.EmailAddress,
|
Email = user.EmailAddress,
|
||||||
UserName = user.UserName
|
UserName = user.UserName
|
||||||
};
|
};
|
||||||
BackgroundJob.Enqueue(() => WelcomeEmail.SendEmail(ombiUser));
|
await WelcomeEmail.SendEmail(ombiUser);
|
||||||
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("accesstoken")]
|
[HttpGet("accesstoken")]
|
||||||
|
|
|
@ -6,17 +6,14 @@ using Ombi.Store.Entities.Requests;
|
||||||
using Ombi.Store.Repository;
|
using Ombi.Store.Repository;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Ombi.Attributes;
|
using Ombi.Attributes;
|
||||||
using Ombi.Core;
|
using Ombi.Core;
|
||||||
using Ombi.Core.Notifications;
|
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Models;
|
using Ombi.Models;
|
||||||
using Ombi.Notifications.Models;
|
using Ombi.Notifications.Models;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using StackExchange.Profiling.Helpers;
|
|
||||||
|
|
||||||
namespace Ombi.Controllers
|
namespace Ombi.Controllers
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
|
||||||
using Ombi.Api.Service;
|
|
||||||
using Ombi.Attributes;
|
using Ombi.Attributes;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Schedule;
|
|
||||||
using Ombi.Schedule.Jobs;
|
using Ombi.Schedule.Jobs;
|
||||||
using Ombi.Schedule.Jobs.Emby;
|
using Ombi.Schedule.Jobs.Emby;
|
||||||
using Ombi.Schedule.Jobs.Ombi;
|
using Ombi.Schedule.Jobs.Ombi;
|
||||||
|
|
|
@ -7,10 +7,8 @@ using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Hangfire;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NCrontab;
|
|
||||||
using Ombi.Api.Emby;
|
using Ombi.Api.Emby;
|
||||||
using Ombi.Attributes;
|
using Ombi.Attributes;
|
||||||
using Ombi.Core.Models.UI;
|
using Ombi.Core.Models.UI;
|
||||||
|
@ -28,7 +26,6 @@ using Ombi.Store.Repository;
|
||||||
using Ombi.Api.Github;
|
using Ombi.Api.Github;
|
||||||
using Ombi.Core.Engine;
|
using Ombi.Core.Engine;
|
||||||
using Ombi.Extensions;
|
using Ombi.Extensions;
|
||||||
using Ombi.Schedule;
|
|
||||||
using Quartz;
|
using Quartz;
|
||||||
|
|
||||||
namespace Ombi.Controllers
|
namespace Ombi.Controllers
|
||||||
|
|
|
@ -65,11 +65,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoMapper" Version="6.1.1" />
|
<PackageReference Include="AutoMapper" Version="6.1.1" />
|
||||||
<PackageReference Include="CommandLineParser" Version="2.1.1-beta" />
|
<PackageReference Include="CommandLineParser" Version="2.1.1-beta" />
|
||||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.6.22" />
|
|
||||||
<PackageReference Include="Hangfire.Console" Version="1.3.10" />
|
|
||||||
<PackageReference Include="Hangfire.MemoryStorage.Core" Version="1.4.0" />
|
|
||||||
<PackageReference Include="Hangfire.RecurringJobExtensions" Version="1.1.6" />
|
|
||||||
<PackageReference Include="Hangfire.SQLite" Version="1.4.2" />
|
|
||||||
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using AutoMapper.EquivalencyExpression;
|
using AutoMapper.EquivalencyExpression;
|
||||||
using Hangfire;
|
|
||||||
using Hangfire.Dashboard;
|
|
||||||
using Hangfire.MemoryStorage;
|
|
||||||
using Hangfire.SQLite;
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
|
@ -93,13 +89,6 @@ namespace Ombi
|
||||||
services.AddSwagger();
|
services.AddSwagger();
|
||||||
services.AddAppSettingsValues(Configuration);
|
services.AddAppSettingsValues(Configuration);
|
||||||
|
|
||||||
services.AddHangfire(x =>
|
|
||||||
{
|
|
||||||
x.UseMemoryStorage();
|
|
||||||
x.UseActivator(new IoCJobActivator(services.BuildServiceProvider()));
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
services.AddCors(o => o.AddPolicy("MyPolicy", builder =>
|
services.AddCors(o => o.AddPolicy("MyPolicy", builder =>
|
||||||
{
|
{
|
||||||
builder.AllowAnyOrigin()
|
builder.AllowAnyOrigin()
|
||||||
|
@ -176,19 +165,7 @@ namespace Ombi
|
||||||
app.UsePathBase(settings.BaseUrl);
|
app.UsePathBase(settings.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHangfireServer(new BackgroundJobServerOptions { WorkerCount = 1, ServerTimeout = TimeSpan.FromDays(1), ShutdownTimeout = TimeSpan.FromDays(1)});
|
// Setup the scheduler
|
||||||
if (env.IsDevelopment())
|
|
||||||
{
|
|
||||||
app.UseHangfireDashboard(settings.BaseUrl.HasValue() ? $"{settings.BaseUrl}/hangfire" : "/hangfire",
|
|
||||||
new DashboardOptions
|
|
||||||
{
|
|
||||||
Authorization = new[] { new HangfireAuthorizationFilter() }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 3 });
|
|
||||||
|
|
||||||
// Setup the scheduler
|
|
||||||
//var jobSetup = app.ApplicationServices.GetService<IJobSetup>();
|
//var jobSetup = app.ApplicationServices.GetService<IJobSetup>();
|
||||||
//jobSetup.Setup();
|
//jobSetup.Setup();
|
||||||
ctx.Seed();
|
ctx.Seed();
|
||||||
|
@ -233,12 +210,4 @@ namespace Ombi
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HangfireAuthorizationFilter : IDashboardAuthorizationFilter
|
|
||||||
{
|
|
||||||
public bool Authorize(DashboardContext context)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue