V8: Send notifications for move, restore, copy and delete actions (#5255)
This commit is contained in:
committed by
Sebastiaan Janssen
parent
9280c74062
commit
7eddc22bba
@@ -41,14 +41,20 @@ namespace Umbraco.Web.Compose
|
||||
//Send notifications for the update and created actions
|
||||
ContentService.Saved += (sender, args) => ContentServiceSaved(_notifier, sender, args, _actions);
|
||||
|
||||
//Send notifications for the delete action
|
||||
ContentService.Deleted += (sender, args) => _notifier.Notify(_actions.GetAction<ActionDelete>(), args.DeletedEntities.ToArray());
|
||||
|
||||
//Send notifications for the unpublish action
|
||||
ContentService.Unpublished += (sender, args) => _notifier.Notify(_actions.GetAction<ActionUnpublish>(), args.PublishedEntities.ToArray());
|
||||
|
||||
//Send notifications for the move/move to recycle bin and restore actions
|
||||
ContentService.Moved += (sender, args) => ContentServiceMoved(_notifier, sender, args, _actions);
|
||||
|
||||
//Send notifications for the delete action when content is moved to the recycle bin
|
||||
ContentService.Trashed += (sender, args) => _notifier.Notify(_actions.GetAction<ActionDelete>(), args.MoveInfoCollection.Select(m => m.Entity).ToArray());
|
||||
|
||||
//Send notifications for the copy action
|
||||
ContentService.Copied += (sender, args) => _notifier.Notify(_actions.GetAction<ActionCopy>(), args.Original);
|
||||
|
||||
//Send notifications for the rollback action
|
||||
ContentService.RolledBack += (sender, args) => _notifier.Notify(_actions.GetAction<ActionRollback>(), args.Entity);
|
||||
ContentService.RolledBack += (sender, args) => _notifier.Notify(_actions.GetAction<ActionRollback>(), args.Entity);
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
@@ -92,6 +98,22 @@ namespace Umbraco.Web.Compose
|
||||
notifier.Notify(actions.GetAction<ActionNew>(), newEntities.ToArray());
|
||||
notifier.Notify(actions.GetAction<ActionUpdate>(), updatedEntities.ToArray());
|
||||
}
|
||||
|
||||
private void ContentServiceMoved(Notifier notifier, IContentService sender, Core.Events.MoveEventArgs<IContent> args, ActionCollection actions)
|
||||
{
|
||||
// notify about the move for all moved items
|
||||
_notifier.Notify(_actions.GetAction<ActionMove>(), args.MoveInfoCollection.Select(m => m.Entity).ToArray());
|
||||
|
||||
// for any items being moved from the recycle bin (restored), explicitly notify about that too
|
||||
var restoredEntities = args.MoveInfoCollection
|
||||
.Where(m => m.OriginalPath.Contains(Constants.System.RecycleBinContentString))
|
||||
.Select(m => m.Entity)
|
||||
.ToArray();
|
||||
if(restoredEntities.Any())
|
||||
{
|
||||
_notifier.Notify(_actions.GetAction<ActionRestore>(), restoredEntities);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This class is used to send the notifications
|
||||
|
||||
Reference in New Issue
Block a user