From 66aa101019c4c4b34e186db9d303049d02b9c781 Mon Sep 17 00:00:00 2001 From: sephrat <34862846+sephrat@users.noreply.github.com> Date: Wed, 7 Sep 2022 17:14:43 +0200 Subject: [PATCH] feat(notifications): Add more curly variables for partially available notification * feat: Add more curly variables for partially available notification * test: Fix newly added test --- .../NotificationMessageCurlysTests.cs | 4 ++++ src/Ombi.Notifications/NotificationMessageCurlys.cs | 12 ++++++++++++ src/Ombi.Schedule/Jobs/ArrAvailabilityChecker.cs | 2 ++ .../Jobs/Emby/EmbyAvaliabilityChecker.cs | 2 ++ .../Jobs/Jellyfin/JellyfinAvaliabilityChecker.cs | 2 ++ .../Jobs/Plex/PlexAvailabilityChecker.cs | 2 ++ src/Ombi.Store/Context/OmbiContext.cs | 2 +- 7 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Ombi.Notifications.Tests/NotificationMessageCurlysTests.cs b/src/Ombi.Notifications.Tests/NotificationMessageCurlysTests.cs index 783844a82..2ea500872 100644 --- a/src/Ombi.Notifications.Tests/NotificationMessageCurlysTests.cs +++ b/src/Ombi.Notifications.Tests/NotificationMessageCurlysTests.cs @@ -292,6 +292,8 @@ namespace Ombi.Notifications.Tests notificationOptions.Substitutes.Add("Season", "1"); notificationOptions.Substitutes.Add("Episodes", "1, 2"); + notificationOptions.Substitutes.Add("EpisodesCount", "2"); + notificationOptions.Substitutes.Add("SeasonEpisodes", "1x1, 1x2"); var req = F.Build() .With(x => x.RequestType, RequestType.TvShow) .With(x => x.Available, true) @@ -324,6 +326,8 @@ namespace Ombi.Notifications.Tests Assert.That("name", Is.EqualTo(sut.ApplicationName)); Assert.That(sut.PartiallyAvailableEpisodeNumbers, Is.EqualTo("1, 2")); Assert.That(sut.PartiallyAvailableSeasonNumber, Is.EqualTo("1")); + Assert.That(sut.PartiallyAvailableEpisodeCount, Is.EqualTo("2")); + Assert.That(sut.PartiallyAvailableEpisodesList, Is.EqualTo("1x1, 1x2")); } [Test] diff --git a/src/Ombi.Notifications/NotificationMessageCurlys.cs b/src/Ombi.Notifications/NotificationMessageCurlys.cs index 7696c9c16..f079c03a3 100644 --- a/src/Ombi.Notifications/NotificationMessageCurlys.cs +++ b/src/Ombi.Notifications/NotificationMessageCurlys.cs @@ -186,6 +186,14 @@ namespace Ombi.Notifications { PartiallyAvailableEpisodeNumbers = epNumber; } + if (opts.Substitutes.TryGetValue("EpisodesCount", out var epCount)) + { + PartiallyAvailableEpisodeCount = epCount; + } + if (opts.Substitutes.TryGetValue("SeasonEpisodes", out var sEpisodes)) + { + PartiallyAvailableEpisodesList = sEpisodes; + } } } @@ -295,6 +303,8 @@ namespace Ombi.Notifications public string ProviderId { get; set; } public string PartiallyAvailableEpisodeNumbers { get; set; } public string PartiallyAvailableSeasonNumber { get; set; } + public string PartiallyAvailableEpisodeCount { get; set; } + public string PartiallyAvailableEpisodesList { get; set; } // System Defined private string LongDate => DateTime.Now.ToString("D"); @@ -336,6 +346,8 @@ namespace Ombi.Notifications { nameof(ProviderId), ProviderId }, { nameof(PartiallyAvailableEpisodeNumbers), PartiallyAvailableEpisodeNumbers }, { nameof(PartiallyAvailableSeasonNumber), PartiallyAvailableSeasonNumber }, + { nameof(PartiallyAvailableEpisodesList), PartiallyAvailableEpisodesList }, + { nameof(PartiallyAvailableEpisodeCount), PartiallyAvailableEpisodeCount }, }; } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/ArrAvailabilityChecker.cs b/src/Ombi.Schedule/Jobs/ArrAvailabilityChecker.cs index d20f906c6..c113c64fd 100644 --- a/src/Ombi.Schedule/Jobs/ArrAvailabilityChecker.cs +++ b/src/Ombi.Schedule/Jobs/ArrAvailabilityChecker.cs @@ -212,6 +212,8 @@ namespace Ombi.Schedule.Jobs.Radarr }; notification.Substitutes.Add("Season", availableEpisode.First().SeasonNumber.ToString()); notification.Substitutes.Add("Episodes", string.Join(", ", availableEpisode.Select(x => x.EpisodeNumber))); + notification.Substitutes.Add("EpisodesCount", $"{availableEpisode.Count}"); + notification.Substitutes.Add("SeasonEpisodes", string.Join(", ", availableEpisode.Select(x => $"{x.SeasonNumber}x{x.EpisodeNumber}" ))); await _notification.Notify(notification); } } diff --git a/src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs b/src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs index 8e8b75e45..1ac49ee3d 100644 --- a/src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs +++ b/src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs @@ -227,6 +227,8 @@ namespace Ombi.Schedule.Jobs.Emby }; notification.Substitutes.Add("Season", availableEpisode.First().SeasonNumber.ToString()); notification.Substitutes.Add("Episodes", string.Join(", ", availableEpisode.Select(x => x.EpisodeNumber))); + notification.Substitutes.Add("EpisodesCount", $"{availableEpisode.Count}"); + notification.Substitutes.Add("SeasonEpisodes", string.Join(", ", availableEpisode.Select(x => $"{x.SeasonNumber}x{x.EpisodeNumber}" ))); await _notificationService.Notify(notification); } } diff --git a/src/Ombi.Schedule/Jobs/Jellyfin/JellyfinAvaliabilityChecker.cs b/src/Ombi.Schedule/Jobs/Jellyfin/JellyfinAvaliabilityChecker.cs index 79eb5d6a4..574de4c36 100644 --- a/src/Ombi.Schedule/Jobs/Jellyfin/JellyfinAvaliabilityChecker.cs +++ b/src/Ombi.Schedule/Jobs/Jellyfin/JellyfinAvaliabilityChecker.cs @@ -253,6 +253,8 @@ namespace Ombi.Schedule.Jobs.Jellyfin }; notification.Substitutes.Add("Season", availableEpisode.First().SeasonNumber.ToString()); notification.Substitutes.Add("Episodes", string.Join(", ", availableEpisode.Select(x => x.EpisodeNumber))); + notification.Substitutes.Add("EpisodesCount", $"{availableEpisode.Count}"); + notification.Substitutes.Add("SeasonEpisodes", string.Join(", ", availableEpisode.Select(x => $"{x.SeasonNumber}x{x.EpisodeNumber}" ))); await _notificationService.Notify(notification); } } diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs b/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs index e686c6dee..6b878f551 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs @@ -174,6 +174,8 @@ namespace Ombi.Schedule.Jobs.Plex }; notification.Substitutes.Add("Season", availableEpisode.First().SeasonNumber.ToString()); notification.Substitutes.Add("Episodes", string.Join(", " ,availableEpisode.Select(x => x.EpisodeNumber))); + notification.Substitutes.Add("EpisodesCount", $"{availableEpisode.Count}"); + notification.Substitutes.Add("SeasonEpisodes", string.Join(", ", availableEpisode.Select(x => $"{x.SeasonNumber}x{x.EpisodeNumber}" ))); await _notificationService.Notify(notification); } } diff --git a/src/Ombi.Store/Context/OmbiContext.cs b/src/Ombi.Store/Context/OmbiContext.cs index b41a541d3..0139e2adc 100644 --- a/src/Ombi.Store/Context/OmbiContext.cs +++ b/src/Ombi.Store/Context/OmbiContext.cs @@ -213,7 +213,7 @@ namespace Ombi.Store.Context notificationToAdd = new NotificationTemplates { NotificationType = notificationType, - Message = "Your TV request for {Title} is now partially available! Season {PartiallyAvailableSeasonNumber} Episodes {PartiallyAvailableEpisodeNumbers}!", + Message = "Your TV request for {Title} is now partially available! Episodes {PartiallyAvailableEpisodesList}!", Subject = "{ApplicationName}: Partially Available Request!", Agent = agent, Enabled = true,