Skip to content

Commit 546849d

Browse files
kjacAndyButland
authored andcommitted
Make notification service able to handle segmented content (#20160)
1 parent aba82dd commit 546849d

File tree

1 file changed

+38
-43
lines changed

1 file changed

+38
-43
lines changed

src/Umbraco.Core/Services/NotificationService.cs

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -374,47 +374,7 @@ private NotificationRequest CreateNotificationRequest(
374374
// build summary
375375
var summary = new StringBuilder();
376376

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

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

0 commit comments

Comments
 (0)