Skip to content

Commit

Permalink
Fix: Linkify logo in newsletter (#5036)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Update src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs

Co-authored-by: Jamie <[email protected]>

---------

Co-authored-by: Jamie <[email protected]>
  • Loading branch information
Unimatrix0 and tidusjar authored Nov 9, 2023
1 parent 3f34375 commit 8779610
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Ombi.Notifications.Templates/INewsletterTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
6 changes: 4 additions & 2 deletions src/Ombi.Notifications.Templates/NewsletterTemplate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Text;
using Ombi.I18n.Resources;
Expand Down Expand Up @@ -27,6 +27,7 @@ public override string TemplateLocation

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}";
Expand All @@ -35,13 +36,14 @@ public override string TemplateLocation
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@
<tbody>
<tr>
<td valign="top" style="font-family: 'Open Sans', Helvetica, Arial, sans-serif; vertical-align: top;">
<img src="{@LOGO}" style="border: none; -ms-interpolation-mode: bicubic; max-width: 100%;">
<a href="{@APPURL}"><img src="{@LOGO}" style="border: none; -ms-interpolation-mode: bicubic; max-width: 100%;"></a>
</td>
</tr>
<tr>
Expand Down
4 changes: 2 additions & 2 deletions src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public async Task Start(NewsletterSettings settings, bool test)
}

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
{
Expand Down Expand Up @@ -216,7 +216,7 @@ public async Task Start(NewsletterSettings settings, bool test)

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 },
Expand Down

0 comments on commit 8779610

Please sign in to comment.