From a0c783ea81bc22d751d0d7a5cff286de7630b745 Mon Sep 17 00:00:00 2001 From: distaula Date: Fri, 24 Feb 2017 12:01:23 -0500 Subject: [PATCH 1/5] fixup! Reset the branch on v2.1.0 tag to get to a shared state between dev and Master. --- Ombi.Core/SettingModels/UserManagementSettings.cs | 1 + Ombi.Helpers/Permissions/Permissions.cs | 5 ++++- Ombi.UI/Modules/RequestsModule.cs | 8 ++++++-- .../UserManagementSettings/UserManagementSettings.cshtml | 3 ++- 4 files changed, 13 insertions(+), 4 deletions(-) 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.UI/Modules/RequestsModule.cs b/Ombi.UI/Modules/RequestsModule.cs index 699b19b67..e59e63a68 100644 --- a/Ombi.UI/Modules/RequestsModule.cs +++ b/Ombi.UI/Modules/RequestsModule.cs @@ -164,6 +164,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, @@ -180,7 +182,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, @@ -247,6 +249,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, @@ -263,7 +267,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, diff --git a/Ombi.UI/Views/UserManagementSettings/UserManagementSettings.cshtml b/Ombi.UI/Views/UserManagementSettings/UserManagementSettings.cshtml index db0fae5f2..dcbe8a32f 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") From c3cba15b1785b310e2d35e2d6247bc40742c93e6 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Sat, 4 Mar 2017 22:01:07 +0000 Subject: [PATCH 2/5] typo --- Ombi.Core.Migration/Migrations/Version2200.cs | 2 +- Ombi.UI/Modules/RequestsModule.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) 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.UI/Modules/RequestsModule.cs b/Ombi.UI/Modules/RequestsModule.cs index cf14ea26f..e10a7775e 100644 --- a/Ombi.UI/Modules/RequestsModule.cs +++ b/Ombi.UI/Modules/RequestsModule.cs @@ -382,7 +382,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) From c95e7368aeb57cb27ddeb35e1570f9206057fdd6 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 6 Mar 2017 20:54:31 +0000 Subject: [PATCH 3/5] Fixed a bug in the Plex Newsletter --- .../PlexRecentlyAddedNewsletter.cs | 22 ++++++++++++++++--- Ombi.Store/TableCreation.cs | 3 ++- 2 files changed, 21 insertions(+), 4 deletions(-) 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; From dfbe01b3bfbf4acdd611ea4ac1b619bd9c0d7dc0 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 6 Mar 2017 21:33:23 +0000 Subject: [PATCH 4/5] Another newsletter fix attempt #1163 #1116 --- Ombi.Services/Jobs/EmbyContentCacher.cs | 15 ++++++++++++++- Ombi.Services/Jobs/EmbyEpisodeCacher.cs | 10 ++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) 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 From 7f70d6ade6c04bb8c6b1d6dd578ec4eccfc1e442 Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Wed, 8 Mar 2017 15:31:28 +0000 Subject: [PATCH 5/5] Fixed #1223 --- Ombi.UI/Modules/Admin/AdminModule.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Ombi.UI/Modules/Admin/AdminModule.cs b/Ombi.UI/Modules/Admin/AdminModule.cs index 388faf926..03b8b7b82 100644 --- a/Ombi.UI/Modules/Admin/AdminModule.cs +++ b/Ombi.UI/Modules/Admin/AdminModule.cs @@ -1132,9 +1132,10 @@ namespace Ombi.UI.Modules.Admin Analytics.TrackEventAsync(Category.Admin, Action.Update, "Update Landing Page", Username, CookieHelper.GetAnalyticClientId(Cookies)); var plexSettings = await PlexService.GetSettingsAsync(); - if (string.IsNullOrEmpty(plexSettings.Ip)) + var embySettings = await EmbySettings.GetSettingsAsync(); + if (string.IsNullOrEmpty(plexSettings.Ip) && string.IsNullOrEmpty(embySettings.Ip)) { - return Response.AsJson(new JsonResponseModel { Result = false, Message = "We cannot enable the landing page if Plex is not setup!" }); + return Response.AsJson(new JsonResponseModel { Result = false, Message = "We cannot enable the landing page if Plex/Emby is not setup!" }); } if (settings.Enabled && settings.EnabledNoticeTime && string.IsNullOrEmpty(settings.NoticeMessage))