Moved the application url to HostingEnvironment and set it in the request middleware
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
@@ -185,7 +186,7 @@ namespace Umbraco.Web.Compose
|
||||
public sealed class Notifier
|
||||
{
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
private readonly IRequestAccessor _requestAccessor;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly INotificationService _notificationService;
|
||||
private readonly IUserService _userService;
|
||||
private readonly ILocalizedTextService _textService;
|
||||
@@ -193,18 +194,11 @@ namespace Umbraco.Web.Compose
|
||||
private readonly ILogger<Notifier> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// Initializes a new instance of the <see cref="Notifier"/> class.
|
||||
/// </summary>
|
||||
/// <param name="backOfficeSecurityAccessor"></param>
|
||||
/// <param name="requestAccessor"></param>
|
||||
/// <param name="notificationService"></param>
|
||||
/// <param name="userService"></param>
|
||||
/// <param name="textService"></param>
|
||||
/// <param name="globalSettings"></param>
|
||||
/// <param name="logger"></param>
|
||||
public Notifier(
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
IRequestAccessor requestAccessor,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
INotificationService notificationService,
|
||||
IUserService userService,
|
||||
ILocalizedTextService textService,
|
||||
@@ -212,7 +206,7 @@ namespace Umbraco.Web.Compose
|
||||
ILogger<Notifier> logger)
|
||||
{
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_requestAccessor = requestAccessor;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_notificationService = notificationService;
|
||||
_userService = userService;
|
||||
_textService = textService;
|
||||
@@ -236,7 +230,7 @@ namespace Umbraco.Web.Compose
|
||||
}
|
||||
}
|
||||
|
||||
SendNotification(user, entities, action, _requestAccessor.GetApplicationUrl());
|
||||
SendNotification(user, entities, action, _hostingEnvironment.ApplicationMainUrl);
|
||||
}
|
||||
|
||||
private void SendNotification(IUser sender, IEnumerable<IContent> entities, IAction action, Uri siteUri)
|
||||
|
||||
@@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Sync;
|
||||
using Umbraco.Web;
|
||||
@@ -19,7 +20,7 @@ namespace Umbraco.Infrastructure.HostedServices
|
||||
/// </summary>
|
||||
public class KeepAlive : RecurringHostedServiceBase
|
||||
{
|
||||
private readonly IRequestAccessor _requestAccessor;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IMainDom _mainDom;
|
||||
private readonly KeepAliveSettings _keepAliveSettings;
|
||||
private readonly ILogger<KeepAlive> _logger;
|
||||
@@ -38,7 +39,7 @@ namespace Umbraco.Infrastructure.HostedServices
|
||||
/// <param name="serverRegistrar">Provider of server registrations to the distributed cache.</param>
|
||||
/// <param name="httpClientFactory">Factory for <see cref="HttpClient" /> instances.</param>
|
||||
public KeepAlive(
|
||||
IRequestAccessor requestAccessor,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IMainDom mainDom,
|
||||
IOptions<KeepAliveSettings> keepAliveSettings,
|
||||
ILogger<KeepAlive> logger,
|
||||
@@ -47,7 +48,7 @@ namespace Umbraco.Infrastructure.HostedServices
|
||||
IHttpClientFactory httpClientFactory)
|
||||
: base(TimeSpan.FromMinutes(5), DefaultDelay)
|
||||
{
|
||||
_requestAccessor = requestAccessor;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_mainDom = mainDom;
|
||||
_keepAliveSettings = keepAliveSettings.Value;
|
||||
_logger = logger;
|
||||
@@ -88,7 +89,7 @@ namespace Umbraco.Infrastructure.HostedServices
|
||||
{
|
||||
if (keepAlivePingUrl.Contains("{umbracoApplicationUrl}"))
|
||||
{
|
||||
var umbracoAppUrl = _requestAccessor.GetApplicationUrl().ToString();
|
||||
var umbracoAppUrl = _hostingEnvironment.ApplicationMainUrl.ToString();
|
||||
if (umbracoAppUrl.IsNullOrWhiteSpace())
|
||||
{
|
||||
_logger.LogWarning("No umbracoApplicationUrl for service (yet), skip.");
|
||||
|
||||
@@ -7,8 +7,8 @@ using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web;
|
||||
|
||||
namespace Umbraco.Infrastructure.HostedServices.ServerRegistration
|
||||
{
|
||||
@@ -19,7 +19,7 @@ namespace Umbraco.Infrastructure.HostedServices.ServerRegistration
|
||||
{
|
||||
private readonly IRuntimeState _runtimeState;
|
||||
private readonly IServerRegistrationService _serverRegistrationService;
|
||||
private readonly IRequestAccessor _requestAccessor;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly ILogger<TouchServerTask> _logger;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
|
||||
@@ -31,12 +31,17 @@ namespace Umbraco.Infrastructure.HostedServices.ServerRegistration
|
||||
/// <param name="requestAccessor">Accessor for the current request.</param>
|
||||
/// <param name="logger">The typed logger.</param>
|
||||
/// <param name="globalSettings">The configuration for global settings.</param>
|
||||
public TouchServerTask(IRuntimeState runtimeState, IServerRegistrationService serverRegistrationService, IRequestAccessor requestAccessor, ILogger<TouchServerTask> logger, IOptions<GlobalSettings> globalSettings)
|
||||
public TouchServerTask(
|
||||
IRuntimeState runtimeState,
|
||||
IServerRegistrationService serverRegistrationService,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
ILogger<TouchServerTask> logger,
|
||||
IOptions<GlobalSettings> globalSettings)
|
||||
: base(globalSettings.Value.DatabaseServerRegistrar.WaitTimeBetweenCalls, TimeSpan.FromSeconds(15))
|
||||
{
|
||||
_runtimeState = runtimeState;
|
||||
_serverRegistrationService = serverRegistrationService ?? throw new ArgumentNullException(nameof(serverRegistrationService));
|
||||
_requestAccessor = requestAccessor;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_logger = logger;
|
||||
_globalSettings = globalSettings.Value;
|
||||
}
|
||||
@@ -48,7 +53,7 @@ namespace Umbraco.Infrastructure.HostedServices.ServerRegistration
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var serverAddress = _requestAccessor.GetApplicationUrl()?.ToString();
|
||||
var serverAddress = _hostingEnvironment.ApplicationMainUrl?.ToString();
|
||||
if (serverAddress.IsNullOrWhiteSpace())
|
||||
{
|
||||
_logger.LogWarning("No umbracoApplicationUrl for service (yet), skip.");
|
||||
|
||||
Reference in New Issue
Block a user