Merge branch 'netcore/dev' of https://github.com/umbraco/Umbraco-CMS into netcore/dev

This commit is contained in:
Shannon
2021-03-16 17:23:55 +11:00
53 changed files with 630 additions and 348 deletions

View File

@@ -5,11 +5,11 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.WebAssets;
using Umbraco.Cms.Infrastructure.DependencyInjection;
using Umbraco.Cms.Infrastructure.WebAssets;
using Umbraco.Cms.Web.BackOffice.Controllers;
@@ -19,6 +19,7 @@ using Umbraco.Cms.Web.BackOffice.ModelsBuilder;
using Umbraco.Cms.Web.BackOffice.Routing;
using Umbraco.Cms.Web.BackOffice.Security;
using Umbraco.Cms.Web.BackOffice.Services;
using Umbraco.Cms.Web.BackOffice.SignalR;
using Umbraco.Cms.Web.BackOffice.Trees;
using Umbraco.Cms.Web.Common.Authorization;
using Umbraco.Cms.Web.Common.Security;
@@ -51,7 +52,8 @@ namespace Umbraco.Extensions
.AddHostedServices()
.AddDistributedCache()
.AddModelsBuilderDashboard()
.AddUnattedInstallCreateUser();
.AddUnattedInstallCreateUser()
.AddExamine();
/// <summary>
/// Adds Umbraco back office authentication requirements
@@ -163,6 +165,7 @@ namespace Umbraco.Extensions
builder.Services.AddUnique<ServerVariablesParser>();
builder.Services.AddUnique<BackOfficeAreaRoutes>();
builder.Services.AddUnique<PreviewRoutes>();
builder.AddNotificationAsyncHandler<ContentCacheRefresherNotification, PreviewHubUpdater>();
builder.Services.AddUnique<BackOfficeServerVariables>();
builder.Services.AddScoped<BackOfficeSessionIdValidator>();
builder.Services.AddScoped<BackOfficeSecurityStampValidator>();

View File

@@ -1,13 +0,0 @@
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
namespace Umbraco.Cms.Web.BackOffice.SignalR
{
public class PreviewHubComposer : ComponentComposer<PreviewHubComponent>, ICoreComposer
{
public override void Compose(IUmbracoBuilder builder)
{
base.Compose(builder);
}
}
}

View File

@@ -1,38 +1,26 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Sync;
namespace Umbraco.Cms.Web.BackOffice.SignalR
{
public class PreviewHubComponent : IComponent
public class PreviewHubUpdater :INotificationAsyncHandler<ContentCacheRefresherNotification>
{
private readonly Lazy<IHubContext<PreviewHub, IPreviewHub>> _hubContext;
// using a lazy arg here means that we won't create the hub until necessary
// and therefore we won't have too bad an impact on boot time
public PreviewHubComponent(Lazy<IHubContext<PreviewHub, IPreviewHub>> hubContext)
public PreviewHubUpdater(Lazy<IHubContext<PreviewHub, IPreviewHub>> hubContext)
{
_hubContext = hubContext;
}
public void Initialize()
{
// ContentService.Saved is too soon - the content cache is not ready yet,
// so use the content cache refresher event, because when it triggers
// the cache has already been notified of the changes
ContentCacheRefresher.CacheUpdated += HandleCacheUpdated;
}
public void Terminate()
{
ContentCacheRefresher.CacheUpdated -= HandleCacheUpdated;
}
private async void HandleCacheUpdated(ContentCacheRefresher sender, CacheRefresherEventArgs args)
{
public async Task HandleAsync(ContentCacheRefresherNotification args, CancellationToken cancellationToken) {
if (args.MessageType != MessageType.RefreshByPayload) return;
var payloads = (ContentCacheRefresher.JsonPayload[])args.MessageObject;
var hubContextInstance = _hubContext.Value;