diff --git a/src/Ombi.Notifications.Templates/EmailBasicTemplate.cs b/src/Ombi.Notifications.Templates/EmailBasicTemplate.cs
index 52febf14e..1088aa3c7 100644
--- a/src/Ombi.Notifications.Templates/EmailBasicTemplate.cs
+++ b/src/Ombi.Notifications.Templates/EmailBasicTemplate.cs
@@ -11,36 +11,29 @@ namespace Ombi.Notifications.Templates
get
{
#if DEBUG
- return Path.Combine(Directory.GetCurrentDirectory(), "bin","Debug", "netcoreapp1.1","Templates", "BasicTemplate.html");
+ return Path.Combine(Directory.GetCurrentDirectory(), "bin", "Debug", "netcoreapp1.1", "Templates", "BasicTemplate.html");
#else
return Path.Combine(Directory.GetCurrentDirectory(), "Templates","BasicTemplate.html");
#endif
}
}
-
-
private const string SubjectKey = "{@SUBJECT}";
private const string BodyKey = "{@BODY}";
private const string ImgSrc = "{@IMGSRC}";
private const string DateKey = "{@DATENOW}";
+ private const string Logo = "{@DATENOW}";
- public string LoadTemplate(string subject, string body, string img)
+ public string LoadTemplate(string subject, string body, string img, string logo)
{
- try
- {
- var sb = new StringBuilder(File.ReadAllText(TemplateLocation));
- sb.Replace(SubjectKey, subject);
- sb.Replace(BodyKey, body);
- sb.Replace(DateKey, DateTime.Now.ToString("f"));
- sb.Replace(ImgSrc, img);
+ var sb = new StringBuilder(File.ReadAllText(TemplateLocation));
+ sb.Replace(SubjectKey, subject);
+ sb.Replace(BodyKey, body);
+ sb.Replace(DateKey, DateTime.Now.ToString("f"));
+ sb.Replace(ImgSrc, img);
+ sb.Replace(Logo, string.IsNullOrEmpty(logo) ? "http://i.imgur.com/qQsN78U.png" : logo);
- return sb.ToString();
- }
- catch (Exception e)
- {
- return string.Empty;
- }
+ return sb.ToString();
}
}
}
diff --git a/src/Ombi.Notifications.Templates/IEmailBasicTemplate.cs b/src/Ombi.Notifications.Templates/IEmailBasicTemplate.cs
index b9ec7b6f3..6b90c796a 100644
--- a/src/Ombi.Notifications.Templates/IEmailBasicTemplate.cs
+++ b/src/Ombi.Notifications.Templates/IEmailBasicTemplate.cs
@@ -2,7 +2,7 @@
{
public interface IEmailBasicTemplate
{
- string LoadTemplate(string subject, string body, string img);
+ string LoadTemplate(string subject, string body, string img, string logo);
string TemplateLocation { get; }
}
}
\ No newline at end of file
diff --git a/src/Ombi.Notifications.Templates/Templates/BasicTemplate.html b/src/Ombi.Notifications.Templates/Templates/BasicTemplate.html
index 3d745ee7f..ac8a1ddfa 100644
--- a/src/Ombi.Notifications.Templates/Templates/BasicTemplate.html
+++ b/src/Ombi.Notifications.Templates/Templates/BasicTemplate.html
@@ -144,7 +144,7 @@
-
+
|
diff --git a/src/Ombi.Notifications/Agents/EmailNotification.cs b/src/Ombi.Notifications/Agents/EmailNotification.cs
index 441901cbd..f702807d2 100644
--- a/src/Ombi.Notifications/Agents/EmailNotification.cs
+++ b/src/Ombi.Notifications/Agents/EmailNotification.cs
@@ -7,6 +7,7 @@ using Ombi.Helpers;
using Ombi.Notifications.Interfaces;
using Ombi.Notifications.Models;
using Ombi.Notifications.Templates;
+using Ombi.Settings.Settings.Models;
using Ombi.Settings.Settings.Models.Notifications;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
@@ -16,11 +17,13 @@ namespace Ombi.Notifications.Agents
{
public class EmailNotification : BaseNotification, IEmailNotification
{
- public EmailNotification(ISettingsService settings, INotificationTemplatesRepository r, IMovieRequestRepository m, ITvRequestRepository t, IEmailProvider prov) : base(settings, r, m, t)
+ public EmailNotification(ISettingsService settings, INotificationTemplatesRepository r, IMovieRequestRepository m, ITvRequestRepository t, IEmailProvider prov, ISettingsService c) : base(settings, r, m, t)
{
EmailProvider = prov;
+ CustomizationSettings = c;
}
private IEmailProvider EmailProvider { get; }
+ private ISettingsService CustomizationSettings { get; }
public override string NotificationName => nameof(EmailNotification);
protected override bool ValidateConfiguration(EmailNotificationSettings settings)
@@ -47,9 +50,11 @@ namespace Ombi.Notifications.Agents
private async Task LoadTemplate(NotificationType type, NotificationOptions model, EmailNotificationSettings settings)
{
var parsed = await LoadTemplate(NotificationAgent.Email, type, model);
-
+
+ var customization = await CustomizationSettings.GetSettingsAsync();
+
var email = new EmailBasicTemplate();
- var html = email.LoadTemplate(parsed.Subject, parsed.Message,parsed.Image);
+ var html = email.LoadTemplate(parsed.Subject, parsed.Message,parsed.Image, customization.Logo);
var message = new NotificationMessage
@@ -108,9 +113,11 @@ namespace Ombi.Notifications.Agents
title = TvRequest.ParentRequest.Title;
img = TvRequest.ParentRequest.PosterPath;
}
+
+ var customization = await CustomizationSettings.GetSettingsAsync();
var html = email.LoadTemplate(
"Ombi: A request could not be added.",
- $"Hello! The user '{user}' has requested {title} but it could not be added. This has been added into the requests queue and will keep retrying", img);
+ $"Hello! The user '{user}' has requested {title} but it could not be added. This has been added into the requests queue and will keep retrying", img, customization.Logo);
var message = new NotificationMessage
{
@@ -173,9 +180,10 @@ namespace Ombi.Notifications.Agents
protected override async Task Test(NotificationOptions model, EmailNotificationSettings settings)
{
var email = new EmailBasicTemplate();
+ var customization = await CustomizationSettings.GetSettingsAsync();
var html = email.LoadTemplate(
"Test Message",
- "This is just a test! Success!", "");
+ "This is just a test! Success!", "", customization.Logo);
var message = new NotificationMessage
{
Message = html,