From 9556ed1b34e153d75096bf9f36616ef473d254da Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Thu, 28 Sep 2017 08:31:25 +0100 Subject: [PATCH] Added an application URL in the customization settings #1513 --- .../NotificationMessageCurlys.cs | 9 ++++++-- .../Settings/Models/CustomizationSettings.cs | 23 ++++++++++++++++++- src/Ombi.Store/Context/OmbiContext.cs | 2 +- .../ClientApp/app/interfaces/ISettings.ts | 1 + .../customization.component.html | 7 ++++++ .../notificationtemplate.component.ts | 1 + src/Ombi/Controllers/IdentityController.cs | 10 ++++---- 7 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/Ombi.Notifications/NotificationMessageCurlys.cs b/src/Ombi.Notifications/NotificationMessageCurlys.cs index 63f94eae5..1cecf5165 100644 --- a/src/Ombi.Notifications/NotificationMessageCurlys.cs +++ b/src/Ombi.Notifications/NotificationMessageCurlys.cs @@ -7,10 +7,11 @@ using Ombi.Store.Entities.Requests; namespace Ombi.Notifications { public class NotificationMessageCurlys - { + { public void Setup(FullBaseRequest req, CustomizationSettings s) { + ApplicationUrl = s.ApplicationUrl; ApplicationName = string.IsNullOrEmpty(s.ApplicationName) ? "Ombi" : s.ApplicationName; RequestedUser = string.IsNullOrEmpty(req.RequestedUser.Alias) ? req.RequestedUser.UserName @@ -25,6 +26,7 @@ namespace Ombi.Notifications public void Setup(ChildRequests req, CustomizationSettings s) { + ApplicationUrl = s.ApplicationUrl; ApplicationName = string.IsNullOrEmpty(s.ApplicationName) ? "Ombi" : s.ApplicationName; RequestedUser = string.IsNullOrEmpty(req.RequestedUser.Alias) ? req.RequestedUser.UserName @@ -40,10 +42,11 @@ namespace Ombi.Notifications public void Setup(OmbiUser user, CustomizationSettings s) { + ApplicationUrl = s.ApplicationUrl; ApplicationName = string.IsNullOrEmpty(s.ApplicationName) ? "Ombi" : s.ApplicationName; RequestedUser = user.UserName; } - + // User Defined public string RequestedUser { get; set; } public string Title { get; set; } @@ -56,6 +59,7 @@ namespace Ombi.Notifications public string SeasonsList { get; set; } public string PosterImage { get; set; } public string ApplicationName { get; set; } + public string ApplicationUrl { get; set; } // System Defined private string LongDate => DateTime.Now.ToString("D"); @@ -80,6 +84,7 @@ namespace Ombi.Notifications {nameof(SeasonsList),SeasonsList}, {nameof(PosterImage),PosterImage}, {nameof(ApplicationName),ApplicationName}, + {nameof(ApplicationUrl),ApplicationUrl}, }; } } \ No newline at end of file diff --git a/src/Ombi.Settings/Settings/Models/CustomizationSettings.cs b/src/Ombi.Settings/Settings/Models/CustomizationSettings.cs index 3227cdf24..a9340e633 100644 --- a/src/Ombi.Settings/Settings/Models/CustomizationSettings.cs +++ b/src/Ombi.Settings/Settings/Models/CustomizationSettings.cs @@ -1,8 +1,29 @@ -namespace Ombi.Settings.Settings.Models +using Newtonsoft.Json; + +namespace Ombi.Settings.Settings.Models { public class CustomizationSettings : Settings { public string ApplicationName { get; set; } + public string ApplicationUrl { get; set; } + + public void AddToUrl(string part) + { + if (string.IsNullOrEmpty(ApplicationUrl)) + { + ApplicationUrl = part; + } + + if (ApplicationUrl.EndsWith("/")) + { + ApplicationUrl.Remove(ApplicationUrl.Length - 1); + } + if (!part.StartsWith("/")) + { + part = "/" + part; + } + ApplicationUrl = ApplicationUrl + part; + } public string Logo { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Store/Context/OmbiContext.cs b/src/Ombi.Store/Context/OmbiContext.cs index d38213cd3..68539aa42 100644 --- a/src/Ombi.Store/Context/OmbiContext.cs +++ b/src/Ombi.Store/Context/OmbiContext.cs @@ -170,7 +170,7 @@ namespace Ombi.Store.Context notificationToAdd = new NotificationTemplates { NotificationType = notificationType, - Message = "Hello! You have been invited to use {ApplicationName}!", + Message = "Hello! You have been invited to use {ApplicationName}! You can login here: {ApplicationUrl}", Subject = "Invite to {ApplicationName}", Agent = agent, Enabled = true, diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index 1f952b70e..ce9dc5b37 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -87,6 +87,7 @@ export interface ILandingPageSettings extends ISettings { export interface ICustomizationSettings extends ISettings { applicationName: string; + applicationUrl: string; logo: string; } diff --git a/src/Ombi/ClientApp/app/settings/customization/customization.component.html b/src/Ombi/ClientApp/app/settings/customization/customization.component.html index 84fb002e1..e3716a975 100644 --- a/src/Ombi/ClientApp/app/settings/customization/customization.component.html +++ b/src/Ombi/ClientApp/app/settings/customization/customization.component.html @@ -9,6 +9,13 @@ +
+ +
+ +
+
+
diff --git a/src/Ombi/ClientApp/app/settings/notifications/notificationtemplate.component.ts b/src/Ombi/ClientApp/app/settings/notifications/notificationtemplate.component.ts index 8b6a4b25a..7ee63323d 100644 --- a/src/Ombi/ClientApp/app/settings/notifications/notificationtemplate.component.ts +++ b/src/Ombi/ClientApp/app/settings/notifications/notificationtemplate.component.ts @@ -21,6 +21,7 @@ export class NotificationTemplate { {SeasonsList} : A comma seperated list of seasons requested
{PosterImage} : The requested poster image link
{ApplicationName} : The Application Name from the Customization Settings +{ApplicationUrl} : The Application URL from the Customization Settings {LongDate} : 15 June 2017
{ShortDate} : 15/06/2017
{LongTime} : 16:02:34
diff --git a/src/Ombi/Controllers/IdentityController.cs b/src/Ombi/Controllers/IdentityController.cs index a5a59f964..d94f7bd4e 100644 --- a/src/Ombi/Controllers/IdentityController.cs +++ b/src/Ombi/Controllers/IdentityController.cs @@ -472,16 +472,16 @@ namespace Ombi.Controllers var appName = (string.IsNullOrEmpty(customizationSettings.ApplicationName) ? "Ombi" : customizationSettings.ApplicationName); - - - var url = - $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}"; + + customizationSettings.AddToUrl("/token?token="); + var url = customizationSettings.ApplicationUrl; + await EmailProvider.SendAdHoc(new NotificationMessage { To = user.Email, Subject = $"{appName} Password Reset", Message = $"You recently made a request to reset your {appName} account. Please click the link below to complete the process.

" + - $" Reset " + $" Reset " }, emailSettings); return defaultMessage;