Skip to content

Commit 301be35

Browse files
authored
Make notification service able to handle segmented content (#20160)
1 parent 7c180f6 commit 301be35

File tree

1 file changed

+38
-44
lines changed

1 file changed

+38
-44
lines changed

src/Umbraco.Core/Services/NotificationService.cs

Lines changed: 38 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -385,48 +385,7 @@ private NotificationRequest CreateNotificationRequest(
385385
// build summary
386386
var summary = new StringBuilder();
387387

388-
if (content.ContentType.VariesByNothing())
389-
{
390-
if (!_contentSettings.Notifications.DisableHtmlEmail)
391-
{
392-
// create the HTML summary for invariant content
393-
394-
// list all of the property values like we used to
395-
summary.Append("<table style=\"width: 100 %; \">");
396-
foreach (IProperty p in content.Properties)
397-
{
398-
// TODO: doesn't take into account variants
399-
var newText = p.GetValue() != null ? p.GetValue()?.ToString() : string.Empty;
400-
var oldText = newText;
401-
402-
// check if something was changed and display the changes otherwise display the fields
403-
if (oldDoc?.Properties.Contains(p.PropertyType.Alias) ?? false)
404-
{
405-
IProperty? oldProperty = oldDoc.Properties[p.PropertyType.Alias];
406-
oldText = oldProperty?.GetValue() != null ? oldProperty.GetValue()?.ToString() : string.Empty;
407-
408-
// replace HTML with char equivalent
409-
ReplaceHtmlSymbols(ref oldText);
410-
ReplaceHtmlSymbols(ref newText);
411-
}
412-
413-
// show the values
414-
summary.Append("<tr>");
415-
summary.Append(
416-
"<th style='text-align: left; vertical-align: top; width: 25%;border-bottom: 1px solid #CCC'>");
417-
summary.Append(p.PropertyType.Name);
418-
summary.Append("</th>");
419-
summary.Append("<td style='text-align: left; vertical-align: top;border-bottom: 1px solid #CCC'>");
420-
summary.Append(newText);
421-
summary.Append("</td>");
422-
summary.Append("</tr>");
423-
}
424-
425-
summary.Append("</table>");
426-
}
427-
}
428-
else if (content.ContentType.VariesByCulture())
429-
{
388+
if (content.ContentType.VariesByCulture()) {
430389
// it's variant, so detect what cultures have changed
431390
if (!_contentSettings.Notifications.DisableHtmlEmail)
432391
{
@@ -465,8 +424,43 @@ private NotificationRequest CreateNotificationRequest(
465424
}
466425
else
467426
{
468-
// not supported yet...
469-
throw new NotSupportedException();
427+
if (!_contentSettings.Notifications.DisableHtmlEmail)
428+
{
429+
// create the HTML summary for invariant content
430+
431+
// list all of the property values like we used to
432+
summary.Append("<table style=\"width: 100 %; \">");
433+
foreach (IProperty p in content.Properties)
434+
{
435+
// TODO: doesn't take into account variants
436+
var newText = p.GetValue() != null ? p.GetValue()?.ToString() : string.Empty;
437+
var oldText = newText;
438+
439+
// check if something was changed and display the changes otherwise display the fields
440+
if (oldDoc?.Properties.Contains(p.PropertyType.Alias) ?? false)
441+
{
442+
IProperty? oldProperty = oldDoc.Properties[p.PropertyType.Alias];
443+
oldText = oldProperty?.GetValue() != null ? oldProperty.GetValue()?.ToString() : string.Empty;
444+
445+
// replace HTML with char equivalent
446+
ReplaceHtmlSymbols(ref oldText);
447+
ReplaceHtmlSymbols(ref newText);
448+
}
449+
450+
// show the values
451+
summary.Append("<tr>");
452+
summary.Append(
453+
"<th style='text-align: left; vertical-align: top; width: 25%;border-bottom: 1px solid #CCC'>");
454+
summary.Append(p.PropertyType.Name);
455+
summary.Append("</th>");
456+
summary.Append("<td style='text-align: left; vertical-align: top;border-bottom: 1px solid #CCC'>");
457+
summary.Append(newText);
458+
summary.Append("</td>");
459+
summary.Append("</tr>");
460+
}
461+
462+
summary.Append("</table>");
463+
}
470464
}
471465

472466
var protocol = _globalSettings.UseHttps ? "https" : "http";

0 commit comments

Comments
 (0)