From 8eb29ab9054ef8eb1c770a1efe39acb0ae341899 Mon Sep 17 00:00:00 2001 From: Namaneo Date: Sat, 11 Jan 2020 22:36:30 +0100 Subject: [PATCH 1/5] Add RequestId variable in notification's data --- src/Ombi.Notifications/NotificationMessageCurlys.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Ombi.Notifications/NotificationMessageCurlys.cs b/src/Ombi.Notifications/NotificationMessageCurlys.cs index cedda3735..c0ad1b49d 100644 --- a/src/Ombi.Notifications/NotificationMessageCurlys.cs +++ b/src/Ombi.Notifications/NotificationMessageCurlys.cs @@ -18,6 +18,8 @@ namespace Ombi.Notifications { LoadIssues(opts); + RequestId = req?.Id.ToString(); + string title; if (req == null) { @@ -68,6 +70,8 @@ namespace Ombi.Notifications { LoadIssues(opts); + RequestId = req?.Id.ToString(); + string title; if (req == null) { @@ -114,6 +118,9 @@ namespace Ombi.Notifications public void Setup(NotificationOptions opts, ChildRequests req, CustomizationSettings s, UserNotificationPreferences pref) { LoadIssues(opts); + + RequestId = req?.Id.ToString(); + string title; if (req == null) { @@ -216,6 +223,7 @@ namespace Ombi.Notifications } // User Defined + public string RequestId { get; set; } public string RequestedUser { get; set; } public string UserName { get; set; } public string IssueUser => UserName; @@ -248,6 +256,7 @@ namespace Ombi.Notifications public Dictionary Curlys => new Dictionary { + {nameof(RequestId), RequestId }, {nameof(RequestedUser), RequestedUser }, {nameof(Title), Title }, {nameof(RequestedDate), RequestedDate }, From 56948035f93ae4f54a851da9b1658dd1fd8a139e Mon Sep 17 00:00:00 2001 From: Namaneo Date: Sun, 12 Jan 2020 00:31:11 +0100 Subject: [PATCH 2/5] Call abstract ProcessResult from generic one while searching TV This especially allows to execute search rules, and therefor to fill properties like requested, approved and available statuses --- .../Engine/Demo/DemoTvSearchEngine.cs | 4 ++-- src/Ombi.Core/Engine/TvSearchEngine.cs | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Ombi.Core/Engine/Demo/DemoTvSearchEngine.cs b/src/Ombi.Core/Engine/Demo/DemoTvSearchEngine.cs index edf9c430d..6c3a78a15 100644 --- a/src/Ombi.Core/Engine/Demo/DemoTvSearchEngine.cs +++ b/src/Ombi.Core/Engine/Demo/DemoTvSearchEngine.cs @@ -56,7 +56,7 @@ namespace Ombi.Core.Engine.Demo { continue; } - retVal.Add(ProcessResult(tvMazeSearch)); + retVal.Add(await ProcessResult(tvMazeSearch)); } return retVal; } @@ -78,7 +78,7 @@ namespace Ombi.Core.Engine.Demo } var movieResult = await TvMazeApi.ShowLookup(tv); - responses.Add(ProcessResult(movieResult)); + responses.Add(await ProcessResult(movieResult)); } return responses; diff --git a/src/Ombi.Core/Engine/TvSearchEngine.cs b/src/Ombi.Core/Engine/TvSearchEngine.cs index 3a1fead18..0b27da5c1 100644 --- a/src/Ombi.Core/Engine/TvSearchEngine.cs +++ b/src/Ombi.Core/Engine/TvSearchEngine.cs @@ -61,7 +61,7 @@ namespace Ombi.Core.Engine { continue; } - retVal.Add(ProcessResult(tvMazeSearch)); + retVal.Add(await ProcessResult(tvMazeSearch)); } return retVal; } @@ -123,7 +123,7 @@ namespace Ombi.Core.Engine public async Task> Popular() { var result = await Cache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(), DateTime.Now.AddHours(12)); - var processed = ProcessResults(result); + var processed = await ProcessResults(result); return processed; } @@ -131,37 +131,38 @@ namespace Ombi.Core.Engine { var result = await Cache.GetOrAdd(CacheKeys.AnticipatedTv, async () => await TraktApi.GetAnticipatedShows(), DateTime.Now.AddHours(12)); - var processed = ProcessResults(result); + var processed = await ProcessResults(result); return processed; } public async Task> MostWatches() { var result = await Cache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(), DateTime.Now.AddHours(12)); - var processed = ProcessResults(result); + var processed = await ProcessResults(result); return processed; } public async Task> Trending() { var result = await Cache.GetOrAdd(CacheKeys.TrendingTv, async () => await TraktApi.GetTrendingShows(), DateTime.Now.AddHours(12)); - var processed = ProcessResults(result); + var processed = await ProcessResults(result); return processed; } - protected IEnumerable ProcessResults(IEnumerable items) + protected async Task> ProcessResults(IEnumerable items) { var retVal = new List(); foreach (var tvMazeSearch in items) { - retVal.Add(ProcessResult(tvMazeSearch)); + retVal.Add(await ProcessResult(tvMazeSearch)); } return retVal; } - protected SearchTvShowViewModel ProcessResult(T tvMazeSearch) + protected async Task ProcessResult(T tvMazeSearch) { - return Mapper.Map(tvMazeSearch); + var viewTv = Mapper.Map(tvMazeSearch); + return await ProcessResult(viewTv); } private async Task ProcessResult(SearchTvShowViewModel item) From f8fcc9bea95d0e3fb4185954c1aa741e987ed239 Mon Sep 17 00:00:00 2001 From: Namaneo Date: Sun, 12 Jan 2020 00:31:33 +0100 Subject: [PATCH 3/5] Add Denied and DeniedReason on the SearchViewModel --- src/Ombi.Core/Models/Search/SearchViewModel.cs | 2 ++ src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/Ombi.Core/Models/Search/SearchViewModel.cs b/src/Ombi.Core/Models/Search/SearchViewModel.cs index a388ccfff..a96700553 100644 --- a/src/Ombi.Core/Models/Search/SearchViewModel.cs +++ b/src/Ombi.Core/Models/Search/SearchViewModel.cs @@ -7,6 +7,8 @@ namespace Ombi.Core.Models.Search { public int Id { get; set; } public bool Approved { get; set; } + public bool? Denied { get; set; } + public string DeniedReason { get; set; } public bool Requested { get; set; } public int RequestId { get; set; } public bool Available { get; set; } diff --git a/src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs b/src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs index 2d4482ba9..37d9fddd7 100644 --- a/src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs +++ b/src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs @@ -34,6 +34,8 @@ namespace Ombi.Core.Rule.Rules.Search obj.Requested = true; obj.RequestId = movieRequests.Id; obj.Approved = movieRequests.Approved; + obj.Denied = movieRequests.Denied ?? false; + obj.DeniedReason = movieRequests.DeniedReason; obj.Available = movieRequests.Available; return Success(); @@ -60,6 +62,8 @@ namespace Ombi.Core.Rule.Rules.Search request.Requested = true; request.Approved = tvRequests.ChildRequests.Any(x => x.Approved); + request.Denied = tvRequests.ChildRequests.Any(x => x.Denied ?? false); + request.DeniedReason = tvRequests.ChildRequests.FirstOrDefault(x => x.DeniedReason != null)?.DeniedReason; // Let's modify the seasonsrequested to reflect what we have requested... foreach (var season in request.SeasonRequests) @@ -108,6 +112,8 @@ namespace Ombi.Core.Rule.Rules.Search obj.Requested = true; obj.RequestId = albumRequest.Id; obj.Approved = albumRequest.Approved; + obj.Denied = albumRequest.Denied; + obj.DeniedReason = albumRequest.DeniedReason; obj.Available = albumRequest.Available; return Success(); From 230c22abe1f90ef5d5273b1a42c296e9999a8822 Mon Sep 17 00:00:00 2001 From: Namaneo Date: Mon, 20 Jan 2020 16:13:01 +0100 Subject: [PATCH 4/5] During a TvShow request, notify using the ParentRequest Id if available --- src/Ombi.Notifications/NotificationMessageCurlys.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ombi.Notifications/NotificationMessageCurlys.cs b/src/Ombi.Notifications/NotificationMessageCurlys.cs index c0ad1b49d..4efc948a5 100644 --- a/src/Ombi.Notifications/NotificationMessageCurlys.cs +++ b/src/Ombi.Notifications/NotificationMessageCurlys.cs @@ -119,7 +119,7 @@ namespace Ombi.Notifications { LoadIssues(opts); - RequestId = req?.Id.ToString(); + RequestId = req?.ParentRequestId.ToString(); string title; if (req == null) From 100c3f813dec88e9277fc3291f8bd634dfd6a383 Mon Sep 17 00:00:00 2001 From: Namaneo Date: Tue, 28 Jan 2020 11:52:15 +0100 Subject: [PATCH 5/5] Remove DeniedReason from top-level TV search model --- src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs b/src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs index 37d9fddd7..e5c890450 100644 --- a/src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs +++ b/src/Ombi.Core/Rule/Rules/Search/ExistingRule.cs @@ -63,7 +63,6 @@ namespace Ombi.Core.Rule.Rules.Search request.Requested = true; request.Approved = tvRequests.ChildRequests.Any(x => x.Approved); request.Denied = tvRequests.ChildRequests.Any(x => x.Denied ?? false); - request.DeniedReason = tvRequests.ChildRequests.FirstOrDefault(x => x.DeniedReason != null)?.DeniedReason; // Let's modify the seasonsrequested to reflect what we have requested... foreach (var season in request.SeasonRequests)