diff --git a/Ombi.Core.Migration/Migrations/Version2200.cs b/Ombi.Core.Migration/Migrations/Version2200.cs index 4422846f0..d9069b8d7 100644 --- a/Ombi.Core.Migration/Migrations/Version2200.cs +++ b/Ombi.Core.Migration/Migrations/Version2200.cs @@ -105,7 +105,7 @@ namespace Ombi.Core.Migration.Migrations con.AlterTable("EmbyContent", "ADD", "AddedAt", true, "VARCHAR(50)"); con.AlterTable("EmbyEpisodes", "ADD", "AddedAt", true, "VARCHAR(50)"); - con.AlterTable("PlexContent", "ADD", "ItemID", true, "VARCHAR(100)"); + con.AlterTable("PlexContent", "ADD", "ItemId", true, "VARCHAR(100)"); con.AlterTable("PlexContent", "ADD", "AddedAt", true, "VARCHAR(100)"); } diff --git a/Ombi.Core/SettingModels/UserManagementSettings.cs b/Ombi.Core/SettingModels/UserManagementSettings.cs index 63c38bf1c..e22880164 100644 --- a/Ombi.Core/SettingModels/UserManagementSettings.cs +++ b/Ombi.Core/SettingModels/UserManagementSettings.cs @@ -38,6 +38,7 @@ namespace Ombi.Core.SettingModels public bool UsersCanViewOnlyOwnRequests { get; set; } public bool UsersCanViewOnlyOwnIssues { get; set; } public bool BypassRequestLimit { get; set; } + public bool ViewUsers { get; set; } // Features public bool RecentlyAddedNotification { get; set; } diff --git a/Ombi.Helpers/Permissions/Permissions.cs b/Ombi.Helpers/Permissions/Permissions.cs index bbfe07a4d..161f7f7f3 100644 --- a/Ombi.Helpers/Permissions/Permissions.cs +++ b/Ombi.Helpers/Permissions/Permissions.cs @@ -73,6 +73,9 @@ namespace Ombi.Helpers.Permissions UsersCanViewOnlyOwnIssues = 2048, [Display(Name = "Bypass the request limit")] - BypassRequestLimit = 4096 + BypassRequestLimit = 4096, + + [Display(Name = "User can see who requested")] + ViewUsers = 8192 } } \ No newline at end of file diff --git a/Ombi.Services/Jobs/EmbyContentCacher.cs b/Ombi.Services/Jobs/EmbyContentCacher.cs index a3eacab65..ce8acdc0e 100644 --- a/Ombi.Services/Jobs/EmbyContentCacher.cs +++ b/Ombi.Services/Jobs/EmbyContentCacher.cs @@ -115,7 +115,7 @@ namespace Ombi.Services.Jobs foreach (var item in info.Items) { var movieInfo = EmbyApi.GetInformation(item.Id, EmbyMediaType.Movie, embySettings.ApiKey, - embySettings.AdministratorId, embySettings.FullUri).MovieInformation; + embySettings.AdministratorId, embySettings.FullUri).MovieInformation; ProcessMovies(movieInfo); } } @@ -149,6 +149,12 @@ namespace Ombi.Services.Jobs connection.Dispose(); return media; }); + if (item != null && item.EmbyId != t.Id) + { + // delete this item since the Id has changed + EmbyContent.Delete(item); + item = null; + } if (item == null) { @@ -255,6 +261,13 @@ namespace Ombi.Services.Jobs return media; }); + if (item != null && item.EmbyId != movieInfo.Id) + { + // delete this item since the Id has changed + EmbyContent.Delete(item); + item = null; + } + if (item == null) { // Doesn't exist, insert it diff --git a/Ombi.Services/Jobs/EmbyEpisodeCacher.cs b/Ombi.Services/Jobs/EmbyEpisodeCacher.cs index 387a7dc98..ce313b965 100644 --- a/Ombi.Services/Jobs/EmbyEpisodeCacher.cs +++ b/Ombi.Services/Jobs/EmbyEpisodeCacher.cs @@ -81,6 +81,7 @@ namespace Ombi.Services.Jobs continue; } + // Check it this episode exists var item = Repo.Custom(connection => { @@ -93,6 +94,15 @@ namespace Ombi.Services.Jobs return media; }); + if (item != null) + { + if (item.EmbyId != ep.Id) // The id's dont match, delete it + { + Repo.Delete(item); + item = null; + } + } + if (item == null) { // add it diff --git a/Ombi.Services/Jobs/RecentlyAddedNewsletter/PlexRecentlyAddedNewsletter.cs b/Ombi.Services/Jobs/RecentlyAddedNewsletter/PlexRecentlyAddedNewsletter.cs index 0b37ae813..79687636a 100644 --- a/Ombi.Services/Jobs/RecentlyAddedNewsletter/PlexRecentlyAddedNewsletter.cs +++ b/Ombi.Services/Jobs/RecentlyAddedNewsletter/PlexRecentlyAddedNewsletter.cs @@ -117,12 +117,16 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter var filteredMovies = movie.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList(); var filteredEp = episodes.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList(); - + var filteredSeries = series.Where(x => recentlyAdded.All(c => c.ProviderId != x.ProviderId)).ToList(); var info = new List(); foreach (var m in filteredMovies) { var i = Api.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, m.ItemId); + if (i.Video == null) + { + continue; + } info.Add(new PlexRecentlyAddedModel { Metadata = i, @@ -132,10 +136,14 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter GenerateMovieHtml(info, sb); info.Clear(); - foreach (var t in series) + foreach (var t in filteredSeries) { var i = Api.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, t.ItemId); - + if (i.Directory == null) + { + continue; + + } //var ep = filteredEp.Where(x => x.ShowTitle == t.Title); info.Add(new PlexRecentlyAddedModel { @@ -183,6 +191,14 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter AddedAt = DateTime.UtcNow }); } + foreach (var a in filteredSeries) + { + RecentlyAddedLog.Insert(new RecentlyAddedLog + { + ProviderId = a.ProviderId, + AddedAt = DateTime.UtcNow + }); + } } var escapedHtml = new string(html.Where(c => !char.IsControl(c)).ToArray()); diff --git a/Ombi.Store/TableCreation.cs b/Ombi.Store/TableCreation.cs index e3fc2c3f8..90aad78e5 100644 --- a/Ombi.Store/TableCreation.cs +++ b/Ombi.Store/TableCreation.cs @@ -25,6 +25,7 @@ // *********************************************************************** #endregion +using System; using System.Collections.Generic; using System.Data; using System.Linq; @@ -61,7 +62,7 @@ namespace Ombi.Store { connection.Open(); var result = connection.Query($"PRAGMA table_info({tableName});"); - if (result.Any(x => x.name == newColumn)) + if (result.Any(x => x.name.Equals(newColumn, StringComparison.CurrentCultureIgnoreCase))) { connection.Close(); return; diff --git a/Ombi.UI/Modules/RequestsModule.cs b/Ombi.UI/Modules/RequestsModule.cs index cf14ea26f..8fc65c515 100644 --- a/Ombi.UI/Modules/RequestsModule.cs +++ b/Ombi.UI/Modules/RequestsModule.cs @@ -208,6 +208,8 @@ namespace Ombi.UI.Modules var canManageRequest = Security.HasAnyPermissions(User, Permissions.Administrator, Permissions.ManageRequests); + var allowViewUsers = Security.HasAnyPermissions(User, Permissions.Administrator, Permissions.ViewUsers); + var viewModel = dbMovies.Select(movie => new RequestViewModel { ProviderId = movie.ProviderId, @@ -224,7 +226,7 @@ namespace Ombi.UI.Modules Approved = movie.Available || movie.Approved, Title = movie.Title, Overview = movie.Overview, - RequestedUsers = canManageRequest ? movie.AllUsers.ToArray() : new string[] { }, + RequestedUsers = canManageRequest || allowViewUsers ? movie.AllUsers.ToArray() : new string[] { }, ReleaseYear = movie.ReleaseDate.Year.ToString(), Available = movie.Available, Admin = canManageRequest, @@ -294,6 +296,8 @@ namespace Ombi.UI.Modules var canManageRequest = Security.HasAnyPermissions(User, Permissions.Administrator, Permissions.ManageRequests); + var allowViewUsers = Security.HasAnyPermissions(User, Permissions.Administrator, Permissions.ViewUsers); + var viewModel = dbTv.Select(tv => new RequestViewModel { ProviderId = tv.ProviderId, @@ -310,7 +314,7 @@ namespace Ombi.UI.Modules Approved = tv.Available || tv.Approved, Title = tv.Title, Overview = tv.Overview, - RequestedUsers = canManageRequest ? tv.AllUsers.ToArray() : new string[] { }, + RequestedUsers = canManageRequest || allowViewUsers ? tv.AllUsers.ToArray() : new string[] { }, ReleaseYear = tv.ReleaseDate.Year.ToString(), Available = tv.Available, Admin = canManageRequest, @@ -382,7 +386,6 @@ namespace Ombi.UI.Modules private async Task GetAlbumRequests() { - var settings = PrSettings.GetSettings(); var dbAlbum = await Service.GetAllAsync(); dbAlbum = dbAlbum.Where(x => x.Type == RequestType.Album); if (Security.HasPermissions(User, Permissions.UsersCanViewOnlyOwnRequests) && !IsAdmin) diff --git a/Ombi.UI/Views/UserManagementSettings/UserManagementSettings.cshtml b/Ombi.UI/Views/UserManagementSettings/UserManagementSettings.cshtml index 03164a4ef..af9666b69 100644 --- a/Ombi.UI/Views/UserManagementSettings/UserManagementSettings.cshtml +++ b/Ombi.UI/Views/UserManagementSettings/UserManagementSettings.cshtml @@ -1,4 +1,4 @@ -@using Ombi.UI.Helpers +@using Ombi.UI.Helpers @inherits Nancy.ViewEngines.Razor.NancyRazorViewBase @Html.Partial("Shared/Partial/_Sidebar") @@ -25,6 +25,7 @@ @Html.Checkbox(Model.UsersCanViewOnlyOwnIssues, "UsersCanViewOnlyOwnIssues", "Users can only view their own issues") @Html.Checkbox(Model.UsersCanViewOnlyOwnRequests, "UsersCanViewOnlyOwnRequests", "Users can only view their own requests") @Html.Checkbox(Model.BypassRequestLimit, "BypassRequestLimit", "Bypass the request limit") + @Html.Checkbox(Model.ViewUsers, "ViewUsers", "User can see who made requests")