Small fixes (#4978)

* fix(tv-requests): 🐛 Fixed a small bug where an exception can get thrown when attempting to view TV Requests

* fix(user-importer): 🐛 Fixed an issue where the cleanup wouldn't delete users #4812
4870
Jamie 11 months ago committed by GitHub
parent 3c3edf6273
commit 5bc87b3972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -929,7 +929,14 @@ namespace Ombi.Core.Engine
var playedCount = playedEpisodes.Count();
var toWatchCount = requestedEpisodes.Count();
request.RequestedUserPlayedProgress = 100 * playedCount / toWatchCount;
if (playedCount == 0 || toWatchCount == 0)
{
request.RequestedUserPlayedProgress = 0;
}
else
{
request.RequestedUserPlayedProgress = 100 * playedCount / toWatchCount;
}
}
}

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.VisualBasic;
using Ombi.Core.Authentication;
using Ombi.Store.Entities;
using Ombi.Store.Entities.Requests;

@ -6,6 +6,7 @@ using Ombi.Api.Plex;
using Ombi.Api.Plex.Models;
using Ombi.Api.Plex.Models.Friends;
using Ombi.Core.Authentication;
using Ombi.Core.Engine;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
using Ombi.Helpers;
@ -365,7 +366,7 @@ namespace Ombi.Schedule.Tests
await _subject.Execute(null);
_mocker.Verify<OmbiUserManager>(x => x.DeleteAsync(It.Is<OmbiUser>(x => x.ProviderUserId == "PLEX_ID" && x.Email == "dupe" && x.UserName == "plex")), Times.Once);
_mocker.Verify<IUserDeletionEngine>(x => x.DeleteUser(It.Is<OmbiUser>(x => x.ProviderUserId == "PLEX_ID" && x.Email == "dupe" && x.UserName == "plex")), Times.Once);
}
[Test]
@ -401,7 +402,7 @@ namespace Ombi.Schedule.Tests
await _subject.Execute(null);
_mocker.Verify<OmbiUserManager>(x => x.DeleteAsync(It.Is<OmbiUser>(x => x.ProviderUserId == "PLEX_ID" && x.Email == "dupe" && x.UserName == "plex")), Times.Once);
_mocker.Verify<IUserDeletionEngine>(x => x.DeleteUser(It.Is<OmbiUser>(x => x.ProviderUserId == "PLEX_ID" && x.Email == "dupe" && x.UserName == "plex")), Times.Once);
}
}
}

@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Ombi.Api.Plex;
using Ombi.Core.Authentication;
using Ombi.Core.Engine;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
using Ombi.Helpers;
@ -20,7 +21,8 @@ namespace Ombi.Schedule.Jobs.Plex
public class PlexUserImporter : IPlexUserImporter
{
public PlexUserImporter(IPlexApi api, OmbiUserManager um, ILogger<PlexUserImporter> log,
ISettingsService<PlexSettings> plexSettings, ISettingsService<UserManagementSettings> ums, INotificationHubService notificationHubService)
ISettingsService<PlexSettings> plexSettings, ISettingsService<UserManagementSettings> ums, INotificationHubService notificationHubService,
IUserDeletionEngine userDeletionEngine)
{
_api = api;
_userManager = um;
@ -28,6 +30,7 @@ namespace Ombi.Schedule.Jobs.Plex
_plexSettings = plexSettings;
_userManagementSettings = ums;
_notification = notificationHubService;
_userDeletionEngine = userDeletionEngine;
_plexSettings.ClearCache();
_userManagementSettings.ClearCache();
}
@ -38,7 +41,7 @@ namespace Ombi.Schedule.Jobs.Plex
private readonly ISettingsService<PlexSettings> _plexSettings;
private readonly ISettingsService<UserManagementSettings> _userManagementSettings;
private readonly INotificationHubService _notification;
private readonly IUserDeletionEngine _userDeletionEngine;
public async Task Execute(IJobExecutionContext job)
{
@ -90,7 +93,7 @@ namespace Ombi.Schedule.Jobs.Plex
foreach (var ombiUser in missingUsers)
{
_log.LogInformation("Deleting user {0} not found in Plex Server.", ombiUser.UserName);
await _userManager.DeleteAsync(ombiUser);
await _userDeletionEngine.DeleteUser(ombiUser);
}
}

Loading…
Cancel
Save