From a8f906617a2df9397518f27630b13711b126108a Mon Sep 17 00:00:00 2001 From: tidusjar Date: Fri, 23 Mar 2018 15:43:55 +0000 Subject: [PATCH] Improved the way we use the notification variables, we have now split out the Username and Alias (Requested User is depricated but not removed) --- .../NotificationMessageCurlys.cs | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Ombi.Notifications/NotificationMessageCurlys.cs b/src/Ombi.Notifications/NotificationMessageCurlys.cs index 8309ff045..dec98291b 100644 --- a/src/Ombi.Notifications/NotificationMessageCurlys.cs +++ b/src/Ombi.Notifications/NotificationMessageCurlys.cs @@ -25,9 +25,9 @@ namespace Ombi.Notifications } ApplicationUrl = (s?.ApplicationUrl.HasValue() ?? false) ? s.ApplicationUrl : string.Empty; ApplicationName = string.IsNullOrEmpty(s?.ApplicationName) ? "Ombi" : s?.ApplicationName; - RequestedUser = string.IsNullOrEmpty(req?.RequestedUser?.Alias) - ? req?.RequestedUser?.UserName - : req?.RequestedUser?.Alias; + RequestedUser = req?.RequestedUser?.UserName; + UserName = req?.RequestedUser?.UserName; + Alias = (req?.RequestedUser?.Alias.HasValue() ?? false) ? req?.RequestedUser?.Alias : req?.RequestedUser?.UserName; Title = title; RequestedDate = req?.RequestedDate.ToString("D"); Type = req?.RequestType.ToString(); @@ -43,6 +43,8 @@ namespace Ombi.Notifications ApplicationUrl = (s?.ApplicationUrl.HasValue() ?? false) ? s.ApplicationUrl : string.Empty; ApplicationName = string.IsNullOrEmpty(s?.ApplicationName) ? "Ombi" : s?.ApplicationName; RequestedUser = username.UserName; + UserName = username.UserName; + Alias = username.Alias.HasValue() ? username.Alias : username.UserName; } public void Setup(NotificationOptions opts, ChildRequests req, CustomizationSettings s) @@ -59,9 +61,9 @@ namespace Ombi.Notifications } ApplicationUrl = (s?.ApplicationUrl.HasValue() ?? false) ? s.ApplicationUrl : string.Empty; ApplicationName = string.IsNullOrEmpty(s?.ApplicationName) ? "Ombi" : s?.ApplicationName; - RequestedUser = string.IsNullOrEmpty(req?.RequestedUser.Alias) - ? req?.RequestedUser.UserName - : req?.RequestedUser.Alias; + RequestedUser = req?.RequestedUser?.UserName; + UserName = req?.RequestedUser?.UserName; + Alias = (req?.RequestedUser?.Alias.HasValue() ?? false) ? req?.RequestedUser?.Alias : req?.RequestedUser?.UserName; Title = title; RequestedDate = req?.RequestedDate.ToString("D"); Type = req?.RequestType.ToString(); @@ -88,13 +90,14 @@ namespace Ombi.Notifications IssueStatus = opts.Substitutes.TryGetValue("IssueStatus", out val) ? val : string.Empty; IssueSubject = opts.Substitutes.TryGetValue("IssueSubject", out val) ? val : string.Empty; NewIssueComment = opts.Substitutes.TryGetValue("NewIssueComment", out val) ? val : string.Empty; - RequestedUser = opts.Substitutes.TryGetValue("IssueUser", out val) ? val : string.Empty; + UserName = opts.Substitutes.TryGetValue("IssueUser", out val) ? val : string.Empty; } // User Defined public string RequestedUser { get; set; } - public string UserName => RequestedUser; - public string IssueUser => RequestedUser; + public string UserName { get; set; } + public string IssueUser => UserName; + public string Alias { get; set; } public string Title { get; set; } public string RequestedDate { get; set; } @@ -144,6 +147,7 @@ namespace Ombi.Notifications {nameof(NewIssueComment),NewIssueComment}, {nameof(IssueUser),IssueUser}, {nameof(UserName),UserName}, + {nameof(Alias),Alias}, }; } } \ No newline at end of file