Make notification service able to handle segmented content (#20160)

This commit is contained in:
Kenn Jacobsen
2025-09-17 06:51:10 +02:00
committed by Andy Butland
parent aba82dd522
commit 546849d825

View File

@@ -374,47 +374,7 @@ public class NotificationService : INotificationService
// build summary
var summary = new StringBuilder();
if (content.ContentType.VariesByNothing())
{
if (!_contentSettings.Notifications.DisableHtmlEmail)
{
// create the HTML summary for invariant content
// list all of the property values like we used to
summary.Append("<table style=\"width: 100 %; \">");
foreach (IProperty p in content.Properties)
{
// TODO: doesn't take into account variants
var newText = p.GetValue() != null ? p.GetValue()?.ToString() : string.Empty;
var oldText = newText;
// check if something was changed and display the changes otherwise display the fields
if (oldDoc?.Properties.Contains(p.PropertyType.Alias) ?? false)
{
IProperty? oldProperty = oldDoc.Properties[p.PropertyType.Alias];
oldText = oldProperty?.GetValue() != null ? oldProperty.GetValue()?.ToString() : string.Empty;
// replace HTML with char equivalent
ReplaceHtmlSymbols(ref oldText);
ReplaceHtmlSymbols(ref newText);
}
// show the values
summary.Append("<tr>");
summary.Append(
"<th style='text-align: left; vertical-align: top; width: 25%;border-bottom: 1px solid #CCC'>");
summary.Append(p.PropertyType.Name);
summary.Append("</th>");
summary.Append("<td style='text-align: left; vertical-align: top;border-bottom: 1px solid #CCC'>");
summary.Append(newText);
summary.Append("</td>");
summary.Append("</tr>");
}
summary.Append("</table>");
}
}
else if (content.ContentType.VariesByCulture())
if (content.ContentType.VariesByCulture())
{
// it's variant, so detect what cultures have changed
if (!_contentSettings.Notifications.DisableHtmlEmail)
@@ -454,8 +414,43 @@ public class NotificationService : INotificationService
}
else
{
// not supported yet...
throw new NotSupportedException();
if (!_contentSettings.Notifications.DisableHtmlEmail)
{
// create the HTML summary for invariant content
// list all of the property values like we used to
summary.Append("<table style=\"width: 100 %; \">");
foreach (IProperty p in content.Properties)
{
// TODO: doesn't take into account variants
var newText = p.GetValue() != null ? p.GetValue()?.ToString() : string.Empty;
var oldText = newText;
// check if something was changed and display the changes otherwise display the fields
if (oldDoc?.Properties.Contains(p.PropertyType.Alias) ?? false)
{
IProperty? oldProperty = oldDoc.Properties[p.PropertyType.Alias];
oldText = oldProperty?.GetValue() != null ? oldProperty.GetValue()?.ToString() : string.Empty;
// replace HTML with char equivalent
ReplaceHtmlSymbols(ref oldText);
ReplaceHtmlSymbols(ref newText);
}
// show the values
summary.Append("<tr>");
summary.Append(
"<th style='text-align: left; vertical-align: top; width: 25%;border-bottom: 1px solid #CCC'>");
summary.Append(p.PropertyType.Name);
summary.Append("</th>");
summary.Append("<td style='text-align: left; vertical-align: top;border-bottom: 1px solid #CCC'>");
summary.Append(newText);
summary.Append("</td>");
summary.Append("</tr>");
}
summary.Append("</table>");
}
}
var protocol = _globalSettings.UseHttps ? "https" : "http";