Skip to content

Commit

Permalink
Removed hangfire completly from Ombi
Browse files Browse the repository at this point in the history
  • Loading branch information
tidusjar committed Nov 10, 2019
1 parent 181bd53 commit b41fcb4
Show file tree
Hide file tree
Showing 25 changed files with 15 additions and 130 deletions.
1 change: 0 additions & 1 deletion src/Ombi.Core/Ombi.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="6.1.1" />
<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.EntityFrameworkCore.Sqlite" Version="2.2.2" />
<PackageReference Include="MiniProfiler.AspNetCore" Version="4.0.0-alpha6-79" />
Expand Down
2 changes: 0 additions & 2 deletions src/Ombi.DependencyInjection/IocExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Security.Principal;
using Hangfire;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;

Expand Down Expand Up @@ -183,7 +182,6 @@ public static void RegisterJobs(this IServiceCollection services)
{
services.AddSingleton<QuartzJobRunner>();
services.AddSingleton<IJobFactory, IoCJobFactory>();
services.AddTransient<IBackgroundJobClient, BackgroundJobClient>();

services.AddTransient<IPlexContentSync, PlexContentSync>();
services.AddTransient<IEmbyContentSync, EmbyContentSync>();
Expand Down
1 change: 1 addition & 0 deletions src/Ombi.Schedule.Tests/OmbiQuartzTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Quartz;
using System.Threading;
using System.Threading.Tasks;
using Ombi.Helpers;

namespace Ombi.Schedule.Tests
{
Expand Down
8 changes: 4 additions & 4 deletions src/Ombi.Schedule.Tests/PlexAvailabilityCheckerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System.Linq.Expressions;
using System.Threading.Tasks;
using Castle.Components.DictionaryAdapter;
using Hangfire;
using Moq;
using NUnit.Framework;
using Ombi.Core;
using Ombi.Core.Notifications;
using Ombi.Schedule.Jobs.Plex;
using Ombi.Store.Entities;
Expand All @@ -25,15 +25,15 @@ public void Setup()
_repo = new Mock<IPlexContentRepository>();
_tv = new Mock<ITvRequestRepository>();
_movie = new Mock<IMovieRequestRepository>();
_notify = new Mock<INotificationService>();
Checker = new PlexAvailabilityChecker(_repo.Object, _tv.Object, _movie.Object, _notify.Object, new Mock<IBackgroundJobClient>().Object, null);
_notify = new Mock<INotificationHelper>();
Checker = new PlexAvailabilityChecker(_repo.Object, _tv.Object, _movie.Object, _notify.Object, null);
}


private Mock<IPlexContentRepository> _repo;
private Mock<ITvRequestRepository> _tv;
private Mock<IMovieRequestRepository> _movie;
private Mock<INotificationService> _notify;
private Mock<INotificationHelper> _notify;
private PlexAvailabilityChecker Checker;

[Test]
Expand Down
28 changes: 0 additions & 28 deletions src/Ombi.Schedule/IoCJobActivator.cs

This file was deleted.

2 changes: 0 additions & 2 deletions src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Ombi.Core;
using Ombi.Core.Notifications;
using Ombi.Helpers;
using Ombi.Notifications.Models;
using Ombi.Schedule.Jobs.Ombi;
Expand Down
3 changes: 0 additions & 3 deletions src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.Extensions.Logging;
using Ombi.Api.Emby;
using Ombi.Api.Emby.Models.Movie;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
using Ombi.Helpers;
using Ombi.Schedule.Jobs.Ombi;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Quartz;
using Serilog;
using EmbyMediaType = Ombi.Store.Entities.EmbyMediaType;

namespace Ombi.Schedule.Jobs.Emby
Expand Down
1 change: 0 additions & 1 deletion src/Ombi.Schedule/Jobs/Emby/EmbyEpisodeSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.Extensions.Logging;
using Ombi.Api.Emby;
using Ombi.Core.Settings;
Expand Down
7 changes: 2 additions & 5 deletions src/Ombi.Schedule/Jobs/Lidarr/LidarrAlbumSync.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.Extensions.Logging;
Expand All @@ -18,21 +17,19 @@ namespace Ombi.Schedule.Jobs.Lidarr
public class LidarrAlbumSync : ILidarrAlbumSync
{
public LidarrAlbumSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrAlbumSync> log, ExternalContext ctx,
IBackgroundJobClient job, ILidarrAvailabilityChecker availability)
ILidarrAvailabilityChecker availability)
{
_lidarrSettings = lidarr;
_lidarrApi = lidarrApi;
_logger = log;
_ctx = ctx;
_job = job;
_availability = availability;
}

private readonly ISettingsService<LidarrSettings> _lidarrSettings;
private readonly ILidarrApi _lidarrApi;
private readonly ILogger _logger;
private readonly ExternalContext _ctx;
private readonly IBackgroundJobClient _job;
private readonly ILidarrAvailabilityChecker _availability;

public async Task CacheContent()
Expand Down Expand Up @@ -87,7 +84,7 @@ public async Task CacheContent()
_logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Lidarr Album");
}

_job.Enqueue(() => _availability.Start());
await _availability.Start();
}
}
catch (Exception)
Expand Down
7 changes: 2 additions & 5 deletions src/Ombi.Schedule/Jobs/Lidarr/LidarrArtistSync.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.Extensions.Logging;
Expand All @@ -19,21 +18,19 @@ namespace Ombi.Schedule.Jobs.Lidarr
public class LidarrArtistSync : ILidarrArtistSync
{
public LidarrArtistSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrArtistSync> log, ExternalContext ctx,
IBackgroundJobClient background, ILidarrAlbumSync album)
ILidarrAlbumSync album)
{
_lidarrSettings = lidarr;
_lidarrApi = lidarrApi;
_logger = log;
_ctx = ctx;
_job = background;
_albumSync = album;
}

private readonly ISettingsService<LidarrSettings> _lidarrSettings;
private readonly ILidarrApi _lidarrApi;
private readonly ILogger _logger;
private readonly ExternalContext _ctx;
private readonly IBackgroundJobClient _job;
private readonly ILidarrAlbumSync _albumSync;

public async Task Execute(IJobExecutionContext job)
Expand Down Expand Up @@ -84,7 +81,7 @@ public async Task Execute(IJobExecutionContext job)
_logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Lidarr");
}

_job.Enqueue(() => _albumSync.CacheContent());
await _albumSync.CacheContent();
}
}
catch (Exception)
Expand Down
7 changes: 1 addition & 6 deletions src/Ombi.Schedule/Jobs/Lidarr/LidarrAvailabilityChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Ombi.Core;
using Ombi.Core.Notifications;
using Ombi.Helpers;
using Ombi.Notifications.Models;
using Ombi.Store.Entities;
Expand All @@ -18,20 +16,17 @@ namespace Ombi.Schedule.Jobs.Lidarr
{
public class LidarrAvailabilityChecker : ILidarrAvailabilityChecker
{
public LidarrAvailabilityChecker(IMusicRequestRepository requests, IRepository<LidarrAlbumCache> albums, ILogger<LidarrAvailabilityChecker> log,
IBackgroundJobClient job, INotificationHelper notification)
public LidarrAvailabilityChecker(IMusicRequestRepository requests, IRepository<LidarrAlbumCache> albums, ILogger<LidarrAvailabilityChecker> log, INotificationHelper notification)
{
_cachedAlbums = albums;
_requestRepository = requests;
_logger = log;
_job = job;
_notificationService = notification;
}

private readonly IMusicRequestRepository _requestRepository;
private readonly IRepository<LidarrAlbumCache> _cachedAlbums;
private readonly ILogger _logger;
private readonly IBackgroundJobClient _job;
private readonly INotificationHelper _notificationService;

public async Task Start()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Threading.Tasks;
using Hangfire.Server;

namespace Ombi.Schedule.Jobs.Ombi
{
Expand Down
2 changes: 0 additions & 2 deletions src/Ombi.Schedule/Jobs/Ombi/MediaDatabaseRefresh.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.Extensions.Logging;
using Ombi.Api.Plex;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
using Ombi.Helpers;
Expand Down
2 changes: 0 additions & 2 deletions src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Hangfire;
using Hangfire.Server;
using Microsoft.Extensions.Logging;
using Ombi.Core.Processor;
using Ombi.Core.Settings;
Expand Down
4 changes: 0 additions & 4 deletions src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.Extensions.Logging;
using Ombi.Api.Emby;
using Ombi.Api.TheMovieDb;
Expand All @@ -11,8 +9,6 @@
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
using Ombi.Helpers;
using Ombi.Schedule.Jobs.Emby;
using Ombi.Schedule.Jobs.Plex;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Quartz;
Expand Down
7 changes: 1 addition & 6 deletions src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Ombi.Core;
using Ombi.Core.Notifications;
using Ombi.Helpers;
using Ombi.Notifications.Models;
using Ombi.Store.Entities;
Expand All @@ -20,21 +17,19 @@ namespace Ombi.Schedule.Jobs.Plex
public class PlexAvailabilityChecker : IPlexAvailabilityChecker
{
public PlexAvailabilityChecker(IPlexContentRepository repo, ITvRequestRepository tvRequest, IMovieRequestRepository movies,
INotificationHelper notification, IBackgroundJobClient background, ILogger<PlexAvailabilityChecker> log)
INotificationHelper notification, ILogger<PlexAvailabilityChecker> log)
{
_tvRepo = tvRequest;
_repo = repo;
_movieRepo = movies;
_notificationService = notification;
_backgroundJobClient = background;
_log = log;
}

private readonly ITvRequestRepository _tvRepo;
private readonly IMovieRequestRepository _movieRepo;
private readonly IPlexContentRepository _repo;
private readonly INotificationHelper _notificationService;
private readonly IBackgroundJobClient _backgroundJobClient;
private readonly ILogger _log;

public async Task Execute(IJobExecutionContext job)
Expand Down
1 change: 0 additions & 1 deletion src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Ombi.Api.Plex;
Expand Down
1 change: 0 additions & 1 deletion src/Ombi.Schedule/Jobs/Plex/PlexEpisodeSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Ombi.Api.Plex;
Expand Down
6 changes: 0 additions & 6 deletions src/Ombi.Schedule/Ombi.Schedule.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@

<ItemGroup>
<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="Quartz" Version="3.0.7" />
<PackageReference Include="SharpCompress" Version="0.24.0" />
Expand Down
6 changes: 3 additions & 3 deletions src/Ombi/Controllers/IdentityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Net;
using System.Threading.Tasks;
using AutoMapper;
using Hangfire;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
Expand Down Expand Up @@ -860,15 +859,16 @@ public async Task<OmbiIdentityResult> ResetPassword([FromBody]ResetPasswordToken

[HttpPost("welcomeEmail")]
[PowerUser]
public void SendWelcomeEmail([FromBody] UserViewModel user)
public async Task<IActionResult> SendWelcomeEmail([FromBody] UserViewModel user)
{
var ombiUser = new OmbiUser
{
Alias = user.Alias,
Email = user.EmailAddress,
UserName = user.UserName
};
BackgroundJob.Enqueue(() => WelcomeEmail.SendEmail(ombiUser));
await WelcomeEmail.SendEmail(ombiUser);
return Ok();
}

[HttpGet("accesstoken")]
Expand Down
3 changes: 0 additions & 3 deletions src/Ombi/Controllers/IssuesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@
using Ombi.Store.Repository;
using System.Collections.Generic;
using System.Linq;
using Hangfire;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Ombi.Attributes;
using Ombi.Core;
using Ombi.Core.Notifications;
using Ombi.Helpers;
using Ombi.Models;
using Ombi.Notifications.Models;
using Ombi.Store.Entities;
using StackExchange.Profiling.Helpers;

namespace Ombi.Controllers
{
Expand Down
Loading

0 comments on commit b41fcb4

Please sign in to comment.