V8: Send notifications for changes in public access (#5288)
Co-authored-by: Sebastiaan Janssen <sebastiaan@umbraco.com>
This commit is contained in:
committed by
Sebastiaan Janssen
parent
a6d8b48ab4
commit
e7f4f61f93
@@ -20,11 +20,13 @@ namespace Umbraco.Web.Compose
|
||||
{
|
||||
private readonly Notifier _notifier;
|
||||
private readonly ActionCollection _actions;
|
||||
private readonly IContentService _contentService;
|
||||
|
||||
public NotificationsComponent(Notifier notifier, ActionCollection actions)
|
||||
public NotificationsComponent(Notifier notifier, ActionCollection actions, IContentService contentService)
|
||||
{
|
||||
_notifier = notifier;
|
||||
_actions = actions;
|
||||
_contentService = contentService;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
@@ -54,7 +56,10 @@ namespace Umbraco.Web.Compose
|
||||
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);
|
||||
|
||||
//Send notifications for the public access changed action
|
||||
PublicAccessService.Saved += (sender, args) => PublicAccessServiceSaved(_notifier, sender, args, _contentService, _actions);
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
@@ -115,6 +120,16 @@ namespace Umbraco.Web.Compose
|
||||
}
|
||||
}
|
||||
|
||||
private void PublicAccessServiceSaved(Notifier notifier, IPublicAccessService sender, Core.Events.SaveEventArgs<PublicAccessEntry> args, IContentService contentService, ActionCollection actions)
|
||||
{
|
||||
var entities = contentService.GetByIds(args.SavedEntities.Select(e => e.ProtectedNodeId)).ToArray();
|
||||
if(entities.Any() == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
notifier.Notify(actions.GetAction<ActionProtect>(), entities);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This class is used to send the notifications
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user