Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion EmailNotificationEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Countersoft.Gemini.Commons.Dto.System;
using Countersoft.Gemini.Commons.Entity.Security;
using Unity;
using System.Text.RegularExpressions;

namespace EmailAlerts
{
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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<SchedulerSettings>() : new SchedulerSettings();
Expand Down Expand Up @@ -713,6 +734,11 @@ private void ProcessWatchers(List<IssueDto> 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 ) ) )
Expand Down
4 changes: 2 additions & 2 deletions app.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<description>Sends email notifications to users</description>
<version-major>7</version-major>
<version-minor>0</version-minor>
<version-patch>0</version-patch>
<version-patch>2</version-patch>
<publisher>Countersoft</publisher>
<released>2020-04-10T09:00:00Z</released>
<released>2021-05-26T09:00:00Z</released>
<debug>false</debug>
</app>