missed changes

This commit is contained in:
tidusjar 2022-08-22 21:40:12 +01:00
commit 65b2869ebe
3 changed files with 18 additions and 10 deletions

View file

@ -26,6 +26,7 @@ namespace Ombi.Core.Engine
private readonly IMusicRequestRepository _musicRepository; private readonly IMusicRequestRepository _musicRepository;
private readonly IRepository<Votes> _voteRepository; private readonly IRepository<Votes> _voteRepository;
private readonly IRepository<MobileDevices> _mobileDevicesRepository; private readonly IRepository<MobileDevices> _mobileDevicesRepository;
private readonly IRepository<PlexWatchlistUserError> _watchlistUserError;
public UserDeletionEngine(IMovieRequestRepository movieRepository, public UserDeletionEngine(IMovieRequestRepository movieRepository,
OmbiUserManager userManager, OmbiUserManager userManager,
@ -39,7 +40,8 @@ namespace Ombi.Core.Engine
IRepository<UserNotificationPreferences> notificationPreferencesRepo, IRepository<UserNotificationPreferences> notificationPreferencesRepo,
IRepository<UserQualityProfiles> qualityProfilesRepo, IRepository<UserQualityProfiles> qualityProfilesRepo,
IRepository<Votes> voteRepository, IRepository<Votes> voteRepository,
IRepository<MobileDevices> mobileDevicesRepository IRepository<MobileDevices> mobileDevicesRepository,
IRepository<PlexWatchlistUserError> watchlistUserError
) )
{ {
_movieRepository = movieRepository; _movieRepository = movieRepository;
@ -56,6 +58,7 @@ namespace Ombi.Core.Engine
_userQualityProfiles = qualityProfilesRepo; _userQualityProfiles = qualityProfilesRepo;
_voteRepository = voteRepository; _voteRepository = voteRepository;
_mobileDevicesRepository = mobileDevicesRepository; _mobileDevicesRepository = mobileDevicesRepository;
_watchlistUserError = watchlistUserError;
} }
@ -68,6 +71,7 @@ namespace Ombi.Core.Engine
var musicRequested = _musicRepository.GetAll().Where(x => x.RequestedUserId == userId); var musicRequested = _musicRepository.GetAll().Where(x => x.RequestedUserId == userId);
var notificationPreferences = _userNotificationPreferences.GetAll().Where(x => x.UserId == userId); var notificationPreferences = _userNotificationPreferences.GetAll().Where(x => x.UserId == userId);
var userQuality = await _userQualityProfiles.GetAll().FirstOrDefaultAsync(x => x.UserId == userId); var userQuality = await _userQualityProfiles.GetAll().FirstOrDefaultAsync(x => x.UserId == userId);
var watchlistError = await _watchlistUserError.GetAll().FirstOrDefaultAsync(x => x.UserId == userId);
if (moviesUserRequested.Any()) if (moviesUserRequested.Any())
{ {
@ -89,6 +93,10 @@ namespace Ombi.Core.Engine
{ {
await _userQualityProfiles.Delete(userQuality); await _userQualityProfiles.Delete(userQuality);
} }
if (watchlistError != null)
{
await _watchlistUserError.Delete(watchlistError);
}
// Delete any issues and request logs // Delete any issues and request logs
var issues = _issuesRepository.GetAll().Where(x => x.UserReportedId == userId); var issues = _issuesRepository.GetAll().Where(x => x.UserReportedId == userId);

View file

@ -39,7 +39,7 @@ namespace Ombi.Schedule.Tests
_context = _mocker.GetMock<IJobExecutionContext>(); _context = _mocker.GetMock<IJobExecutionContext>();
_context.Setup(x => x.CancellationToken).Returns(CancellationToken.None); _context.Setup(x => x.CancellationToken).Returns(CancellationToken.None);
_subject = _mocker.CreateInstance<PlexWatchlistImport>(); _subject = _mocker.CreateInstance<PlexWatchlistImport>();
_mocker.Setup<IExternalRepository<PlexWatchlistUserError>, IQueryable<PlexWatchlistUserError>>(x => x.GetAll()).Returns(new List<PlexWatchlistUserError>().AsQueryable().BuildMock().Object); _mocker.Setup<IRepository<PlexWatchlistUserError>, IQueryable<PlexWatchlistUserError>>(x => x.GetAll()).Returns(new List<PlexWatchlistUserError>().AsQueryable().BuildMock().Object);
} }
[Test] [Test]
@ -90,8 +90,8 @@ namespace Ombi.Schedule.Tests
_mocker.Verify<IPlexApi>(x => x.GetWatchlist(It.IsAny<string>(), It.IsAny<CancellationToken>()), Times.Once); _mocker.Verify<IPlexApi>(x => x.GetWatchlist(It.IsAny<string>(), It.IsAny<CancellationToken>()), Times.Once);
_mocker.Verify<IMovieRequestEngine>(x => x.RequestMovie(It.IsAny<MovieRequestViewModel>()), Times.Never); _mocker.Verify<IMovieRequestEngine>(x => x.RequestMovie(It.IsAny<MovieRequestViewModel>()), Times.Never);
_mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.GetAll(), Times.Never); _mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.GetAll(), Times.Never);
_mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.Add(It.IsAny<PlexWatchlistHistory>()), Times.Never); _mocker.Verify<IRepository<PlexWatchlistHistory>>(x => x.Add(It.IsAny<PlexWatchlistHistory>()), Times.Never);
_mocker.Verify<IExternalRepository<PlexWatchlistUserError>>(x => x.Add(It.Is<PlexWatchlistUserError>(x => x.UserId == "abc")), Times.Once); _mocker.Verify<IRepository<PlexWatchlistUserError>>(x => x.Add(It.Is<PlexWatchlistUserError>(x => x.UserId == "abc")), Times.Once);
} }
[Test] [Test]
@ -114,8 +114,8 @@ namespace Ombi.Schedule.Tests
_mocker.Verify<IMovieRequestEngine>(x => x.RequestMovie(It.IsAny<MovieRequestViewModel>()), Times.Never); _mocker.Verify<IMovieRequestEngine>(x => x.RequestMovie(It.IsAny<MovieRequestViewModel>()), Times.Never);
_mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.GetAll(), Times.Never); _mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.GetAll(), Times.Never);
_mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.Add(It.IsAny<PlexWatchlistHistory>()), Times.Never); _mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.Add(It.IsAny<PlexWatchlistHistory>()), Times.Never);
_mocker.Verify<IExternalRepository<PlexWatchlistUserError>>(x => x.Add(It.Is<PlexWatchlistUserError>(x => x.UserId == "abc")), Times.Never); _mocker.Verify<IRepository<PlexWatchlistUserError>>(x => x.Add(It.Is<PlexWatchlistUserError>(x => x.UserId == "abc")), Times.Never);
_mocker.Verify<IExternalRepository<PlexWatchlistUserError>>(x => x.Delete(It.Is<PlexWatchlistUserError>(x => x.UserId == "abc")), Times.Once); _mocker.Verify<IRepository<PlexWatchlistUserError>>(x => x.Delete(It.Is<PlexWatchlistUserError>(x => x.UserId == "abc")), Times.Once);
} }
[Test] [Test]
@ -138,8 +138,8 @@ namespace Ombi.Schedule.Tests
_mocker.Verify<IMovieRequestEngine>(x => x.RequestMovie(It.IsAny<MovieRequestViewModel>()), Times.Never); _mocker.Verify<IMovieRequestEngine>(x => x.RequestMovie(It.IsAny<MovieRequestViewModel>()), Times.Never);
_mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.GetAll(), Times.Never); _mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.GetAll(), Times.Never);
_mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.Add(It.IsAny<PlexWatchlistHistory>()), Times.Never); _mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.Add(It.IsAny<PlexWatchlistHistory>()), Times.Never);
_mocker.Verify<IExternalRepository<PlexWatchlistUserError>>(x => x.Add(It.Is<PlexWatchlistUserError>(x => x.UserId == "abc")), Times.Never); _mocker.Verify<IRepository<PlexWatchlistUserError>>(x => x.Add(It.Is<PlexWatchlistUserError>(x => x.UserId == "abc")), Times.Never);
_mocker.Verify<IExternalRepository<PlexWatchlistUserError>>(x => x.Delete(It.Is<PlexWatchlistUserError>(x => x.UserId == "abc")), Times.Never); _mocker.Verify<IRepository<PlexWatchlistUserError>>(x => x.Delete(It.Is<PlexWatchlistUserError>(x => x.UserId == "abc")), Times.Never);
} }

View file

@ -33,11 +33,11 @@ namespace Ombi.Schedule.Jobs.Plex
private readonly IHubContext<NotificationHub> _hub; private readonly IHubContext<NotificationHub> _hub;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IExternalRepository<PlexWatchlistHistory> _watchlistRepo; private readonly IExternalRepository<PlexWatchlistHistory> _watchlistRepo;
private readonly IExternalRepository<PlexWatchlistUserError> _userError; private readonly IRepository<PlexWatchlistUserError> _userError;
public PlexWatchlistImport(IPlexApi plexApi, ISettingsService<PlexSettings> settings, OmbiUserManager ombiUserManager, public PlexWatchlistImport(IPlexApi plexApi, ISettingsService<PlexSettings> settings, OmbiUserManager ombiUserManager,
IMovieRequestEngine movieRequestEngine, ITvRequestEngine tvRequestEngine, IHubContext<NotificationHub> hub, IMovieRequestEngine movieRequestEngine, ITvRequestEngine tvRequestEngine, IHubContext<NotificationHub> hub,
ILogger<PlexWatchlistImport> logger, IExternalRepository<PlexWatchlistHistory> watchlistRepo, IExternalRepository<PlexWatchlistUserError> userError) ILogger<PlexWatchlistImport> logger, IExternalRepository<PlexWatchlistHistory> watchlistRepo, IRepository<PlexWatchlistUserError> userError)
{ {
_plexApi = plexApi; _plexApi = plexApi;
_settings = settings; _settings = settings;