From ac3f1941bc6d82b12838e2ff2a4b3652b05bc248 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 14 Jun 2021 13:10:04 +0100 Subject: [PATCH] Added the ability to unsubscribe from the newsletter #2137 --- .../INewsletterTemplate.cs | 2 +- .../NewsletterTemplate.cs | 6 +- .../Templates/NewsletterTemplate.html | 5 ++ .../NewsletterUnsubscribeTests.cs | 35 ++++++++++++ src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs | 55 +++++++++++++------ src/Ombi/ClientApp/src/app/app.module.ts | 1 + .../src/app/services/identity.service.ts | 4 ++ .../unsubscribe-confirm.component.html | 3 + .../unsubscribe-confirm.component.ts | 28 ++++++++++ .../src/app/unsubscribe/unsubscribe.module.ts | 27 +++++++++ src/Ombi/Controllers/V1/IdentityController.cs | 16 ++++++ 11 files changed, 161 insertions(+), 21 deletions(-) create mode 100644 src/Ombi.Schedule.Tests/NewsletterUnsubscribeTests.cs create mode 100644 src/Ombi/ClientApp/src/app/unsubscribe/components/confirm-component/unsubscribe-confirm.component.html create mode 100644 src/Ombi/ClientApp/src/app/unsubscribe/components/confirm-component/unsubscribe-confirm.component.ts create mode 100644 src/Ombi/ClientApp/src/app/unsubscribe/unsubscribe.module.ts diff --git a/src/Ombi.Notifications.Templates/INewsletterTemplate.cs b/src/Ombi.Notifications.Templates/INewsletterTemplate.cs index e3302710d..620cf3999 100644 --- a/src/Ombi.Notifications.Templates/INewsletterTemplate.cs +++ b/src/Ombi.Notifications.Templates/INewsletterTemplate.cs @@ -2,6 +2,6 @@ { public interface INewsletterTemplate { - string LoadTemplate(string subject, string intro, string tableHtml, string logo); + string LoadTemplate(string subject, string intro, string tableHtml, string logo, string unsubscribeLink); } } \ No newline at end of file diff --git a/src/Ombi.Notifications.Templates/NewsletterTemplate.cs b/src/Ombi.Notifications.Templates/NewsletterTemplate.cs index 84d92c21c..f2f0cbf12 100644 --- a/src/Ombi.Notifications.Templates/NewsletterTemplate.cs +++ b/src/Ombi.Notifications.Templates/NewsletterTemplate.cs @@ -13,7 +13,7 @@ namespace Ombi.Notifications.Templates if (string.IsNullOrEmpty(_templateLocation)) { #if DEBUG - _templateLocation = Path.Combine(Directory.GetCurrentDirectory(), "bin", "Debug", "netcoreapp3.0", "Templates", "NewsletterTemplate.html"); + _templateLocation = Path.Combine(Directory.GetCurrentDirectory(), "bin", "Debug", "net5.0", "Templates", "NewsletterTemplate.html"); #else _templateLocation = Path.Combine(Directory.GetCurrentDirectory(), "Templates", "NewsletterTemplate.html"); #endif @@ -29,9 +29,10 @@ namespace Ombi.Notifications.Templates private const string Logo = "{@LOGO}"; private const string TableLocation = "{@RECENTLYADDED}"; private const string IntroText = "{@INTRO}"; + private const string Unsubscribe = "{@UNSUBSCRIBE}"; - public string LoadTemplate(string subject, string intro, string tableHtml, string logo) + public string LoadTemplate(string subject, string intro, string tableHtml, string logo, string unsubscribeLink) { var sb = new StringBuilder(File.ReadAllText(TemplateLocation)); sb.Replace(SubjectKey, subject); @@ -39,6 +40,7 @@ namespace Ombi.Notifications.Templates sb.Replace(IntroText, intro); sb.Replace(DateKey, DateTime.Now.ToString("f")); sb.Replace(Logo, string.IsNullOrEmpty(logo) ? OmbiLogo : logo); + sb.Replace(Unsubscribe, string.IsNullOrEmpty(unsubscribeLink) ? string.Empty : unsubscribeLink); return sb.ToString(); } diff --git a/src/Ombi.Notifications.Templates/Templates/NewsletterTemplate.html b/src/Ombi.Notifications.Templates/Templates/NewsletterTemplate.html index 10b76dd30..71666ba67 100644 --- a/src/Ombi.Notifications.Templates/Templates/NewsletterTemplate.html +++ b/src/Ombi.Notifications.Templates/Templates/NewsletterTemplate.html @@ -451,6 +451,11 @@