diff --git a/EmailNotificationEngine.cs b/EmailNotificationEngine.cs index 29882be..e7c4c63 100644 --- a/EmailNotificationEngine.cs +++ b/EmailNotificationEngine.cs @@ -20,6 +20,7 @@ using Countersoft.Gemini.Commons.Dto.System; using Countersoft.Gemini.Commons.Entity.Security; using Unity; +using System.Text.RegularExpressions; namespace EmailAlerts { @@ -255,7 +256,7 @@ private void ProcessAppNavCardAlerts() indModel.LinkViewItem = NavigationHelper.GetIssueUrl(_issueManager.UserContext, issue.Entity.ProjectId, issue.EscapedProjectCode, issue.Entity.Id); - indModel.TheItem = issue; + indModel.TheItem = UpdateIssueLinksForExternalUse(issue); indModel.TheRecipient = user; @@ -374,6 +375,26 @@ private void ProcessAppNavCardAlerts() } } + private IssueDto UpdateIssueLinksForExternalUse( IssueDto issue ) + { + issue.Entity.Description = Regex.Replace( issue.Entity.Description, "href=\"/", "href=\"" + GeminiApp.Config.Url + "/", RegexOptions.IgnoreCase ); + if(issue.Comments != null) + { + issue.Comments.ForEach( c => + { + c.Entity.Comment = Regex.Replace( issue.Entity.Description, "href=\"/", "href=\"" + GeminiApp.Config.Url + "/", RegexOptions.IgnoreCase ); + } ); + } + if(issue.CustomFields != null ) + { + //For performance, won't do it on CFs as their not in default templates, clients can replace in their bespoke template if needed + //issue.CustomFields + //.FindAll( cf => cf.Type == Constants.CUSTOM_FIELD_TYPE_RICHTEXT ) + //.ForEach( cf => cf.FormattedData = Regex.Replace( issue.Entity.Description, "href=\"/", "href=\"" + GeminiApp.Config.Url + "/", RegexOptions.IgnoreCase ) ); + } + return issue; + } + private void ProcessWatcherAlerts() { SchedulerSettings settings = _issueManager.UserContext.Config.SchedulerSettings.HasValue() ? _issueManager.UserContext.Config.SchedulerSettings.FromJson() : new SchedulerSettings(); @@ -713,6 +734,11 @@ private void ProcessWatchers(List issues, DateTime lastChecked) private int? GetLanguageId( UserDto recipient ) { var languageCode = recipient.Entity.Language.EnsureValue(); + if ( string.IsNullOrWhiteSpace( languageCode ) || !languageCode.Contains("-")) + { + base.LogDebugMessage( string.Format( "User {0} does not have a language set", recipient.Entity.Username ) ); + languageCode = "en-US"; //set the default + } var lang = _languages.Find( l => l.Code == languageCode ) ?? _languages.FindAll( l => l.Code.StartsWith( languageCode.Substring( 0, languageCode.IndexOf( "-" ) - 1 ) ) ) diff --git a/app.manifest b/app.manifest index 33facf8..34c7d77 100644 --- a/app.manifest +++ b/app.manifest @@ -4,8 +4,8 @@ Sends email notifications to users 7 0 - 0 + 2 Countersoft - 2020-04-10T09:00:00Z + 2021-05-26T09:00:00Z false