Pass the existing notification state to the ContentUnpublishingNotification so it can be shared. (#14638)

This commit is contained in:
Bjarke Berg
2023-08-08 09:40:44 +02:00
committed by GitHub
parent 4e410a9dd5
commit 512199c8ab

View File

@@ -1542,7 +1542,7 @@ public class ContentService : RepositoryService, IContentService
// handling events, business rules, etc
// note: StrategyUnpublish flips the PublishedState to Unpublishing!
// note: This unpublishes the entire document (not different variants)
unpublishResult = StrategyCanUnpublish(scope, content, eventMessages);
unpublishResult = StrategyCanUnpublish(scope, content, eventMessages, notificationState);
if (unpublishResult.Success)
{
unpublishResult = StrategyUnpublish(content, eventMessages);
@@ -3296,10 +3296,10 @@ public class ContentService : RepositoryService, IContentService
/// <param name="content"></param>
/// <param name="evtMsgs"></param>
/// <returns></returns>
private PublishResult StrategyCanUnpublish(ICoreScope scope, IContent content, EventMessages evtMsgs)
private PublishResult StrategyCanUnpublish(ICoreScope scope, IContent content, EventMessages evtMsgs, IDictionary<string, object?>? notificationState)
{
// raise Unpublishing notification
if (scope.Notifications.PublishCancelable(new ContentUnpublishingNotification(content, evtMsgs)))
if (scope.Notifications.PublishCancelable(new ContentUnpublishingNotification(content, evtMsgs).WithState(notificationState)))
{
_logger.LogInformation(
"Document {ContentName} (id={ContentId}) cannot be unpublished: unpublishing was cancelled.", content.Name, content.Id);