Added an application URL in the customization settings #1513

pull/1520/head
Jamie.Rees 7 years ago
parent 5472baff24
commit 9556ed1b34

@ -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},
};
}
}

@ -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; }
}
}

@ -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,

@ -87,6 +87,7 @@ export interface ILandingPageSettings extends ISettings {
export interface ICustomizationSettings extends ISettings {
applicationName: string;
applicationUrl: string;
logo: string;
}

@ -9,6 +9,13 @@
</div>
</div>
<div class="form-group">
<label for="applicationurl" class="control-label">Application URL</label>
<div>
<input type="text" [(ngModel)]="settings.applicationurl" class="form-control form-control-custom " id="applicationurl" name="applicationurl" placeholder="http://ombi.io/" value="{{settings.applicationurl}}">
</div>
</div>
<div class="form-group">
<label for="logo" class="control-label">Custom Logo</label>
<div>

@ -21,6 +21,7 @@ export class NotificationTemplate {
{SeasonsList} : A comma seperated list of seasons requested<br/>
{PosterImage} : The requested poster image link<br/>
{ApplicationName} : The Application Name from the Customization Settings
{ApplicationUrl} : The Application URL from the Customization Settings
{LongDate} : 15 June 2017 <br/>
{ShortDate} : 15/06/2017 <br/>
{LongTime} : 16:02:34 <br/>

@ -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.<br/><br/>" +
$"<a href=\"{url}/token?token={token}\"> Reset </a>"
$"<a href=\"{url}{token}\"> Reset </a>"
}, emailSettings);
return defaultMessage;

Loading…
Cancel
Save