From 87796102c699d9d4ebdcf066fb5646fa4de3c60b Mon Sep 17 00:00:00 2001 From: Avi <357984+Unimatrix0@users.noreply.github.com> Date: Thu, 9 Nov 2023 17:02:33 -0600 Subject: [PATCH] Fix: Linkify logo in newsletter (#5036) * Update NewsletterJob.cs Begin work to turn logo in newsletter into link to app * Update NewsletterTemplate.cs Add ApplicationUrl * Update INewsletterTemplate.cs Add applicationUrl * Update NewsletterTemplate.html Turn app logo into link to app * Update src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs Co-authored-by: Jamie * Update src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs Co-authored-by: Jamie --------- Co-authored-by: Jamie --- src/Ombi.Notifications.Templates/INewsletterTemplate.cs | 4 ++-- src/Ombi.Notifications.Templates/NewsletterTemplate.cs | 6 ++++-- .../Templates/NewsletterTemplate.html | 2 +- src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Ombi.Notifications.Templates/INewsletterTemplate.cs b/src/Ombi.Notifications.Templates/INewsletterTemplate.cs index 620cf3999..11d0e7431 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 unsubscribeLink); + string LoadTemplate(string subject, string intro, string tableHtml, string logo, string unsubscribeLink, string applicationUrl); } -} \ No newline at end of file +} diff --git a/src/Ombi.Notifications.Templates/NewsletterTemplate.cs b/src/Ombi.Notifications.Templates/NewsletterTemplate.cs index 9d3b1632a..d83197d24 100644 --- a/src/Ombi.Notifications.Templates/NewsletterTemplate.cs +++ b/src/Ombi.Notifications.Templates/NewsletterTemplate.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Text; using Ombi.I18n.Resources; @@ -27,6 +27,7 @@ namespace Ombi.Notifications.Templates private const string SubjectKey = "{@SUBJECT}"; private const string DateKey = "{@DATENOW}"; + private const string AppUrl = "{@APPURL}"; private const string Logo = "{@LOGO}"; private const string TableLocation = "{@RECENTLYADDED}"; private const string IntroText = "{@INTRO}"; @@ -35,13 +36,14 @@ namespace Ombi.Notifications.Templates private const string PoweredByText = "{@POWEREDBYTEXT}"; - public string LoadTemplate(string subject, string intro, string tableHtml, string logo, string unsubscribeLink) + public string LoadTemplate(string subject, string intro, string tableHtml, string logo, string unsubscribeLink, string applicationUrl) { var sb = new StringBuilder(File.ReadAllText(TemplateLocation)); sb.Replace(SubjectKey, subject); sb.Replace(TableLocation, tableHtml); sb.Replace(IntroText, intro); sb.Replace(DateKey, DateTime.Now.ToString("f")); + sb.Replace(AppUrl, applicationUrl); sb.Replace(Logo, string.IsNullOrEmpty(logo) ? OmbiLogo : logo); sb.Replace(Unsubscribe, string.IsNullOrEmpty(unsubscribeLink) ? string.Empty : unsubscribeLink); sb.Replace(UnsubscribeText, string.IsNullOrEmpty(unsubscribeLink) ? string.Empty : Texts.Unsubscribe); diff --git a/src/Ombi.Notifications.Templates/Templates/NewsletterTemplate.html b/src/Ombi.Notifications.Templates/Templates/NewsletterTemplate.html index fdafdb609..12be6b5c4 100644 --- a/src/Ombi.Notifications.Templates/Templates/NewsletterTemplate.html +++ b/src/Ombi.Notifications.Templates/Templates/NewsletterTemplate.html @@ -428,7 +428,7 @@ - + diff --git a/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs b/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs index 0a082bfe6..4107a3bea 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs @@ -174,7 +174,7 @@ namespace Ombi.Schedule.Jobs.Ombi } var url = GenerateUnsubscribeLink(customization.ApplicationUrl, user.Id); - var html = email.LoadTemplate(messageContent.Subject, messageContent.Message, body, customization.Logo, url); + var html = email.LoadTemplate(messageContent.Subject, messageContent.Message, body, customization.Logo, url, customization.ApplicationUrl ?? string.Empty); var bodyBuilder = new BodyBuilder { @@ -216,7 +216,7 @@ namespace Ombi.Schedule.Jobs.Ombi var email = new NewsletterTemplate(); - var html = email.LoadTemplate(messageContent.Subject, messageContent.Message, body, customization.Logo, unsubscribeLink); + var html = email.LoadTemplate(messageContent.Subject, messageContent.Message, body, customization.Logo, unsubscribeLink, customization.ApplicationUrl ?? string.Empty); await _email.Send( new NotificationMessage { Message = html, Subject = messageContent.Subject, To = a.Email },