From 3e95d94726cc6cb9f3be929b97c1c01dc0feb1f1 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 6 Dec 2018 17:24:06 +1100 Subject: [PATCH] fixes build --- .../EmailNotificationMethod.cs | 16 +++++++--------- .../Routing/ContentFinderByRedirectUrl.cs | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Umbraco.Web/HealthCheck/NotificationMethods/EmailNotificationMethod.cs b/src/Umbraco.Web/HealthCheck/NotificationMethods/EmailNotificationMethod.cs index 26fd8b3720..b697c87335 100644 --- a/src/Umbraco.Web/HealthCheck/NotificationMethods/EmailNotificationMethod.cs +++ b/src/Umbraco.Web/HealthCheck/NotificationMethods/EmailNotificationMethod.cs @@ -14,8 +14,10 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods public class EmailNotificationMethod : NotificationMethodBase { private readonly ILocalizedTextService _textService; + private readonly IRuntimeState _runtimeState; + private readonly ILogger _logger; - public EmailNotificationMethod(ILocalizedTextService textService) + public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger) { var recipientEmail = Settings["recipientEmail"]?.Value; if (string.IsNullOrWhiteSpace(recipientEmail)) @@ -27,6 +29,8 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods RecipientEmail = recipientEmail; _textService = textService ?? throw new ArgumentNullException(nameof(textService)); + _runtimeState = runtimeState; + _logger = logger; } public string RecipientEmail { get; } @@ -52,15 +56,9 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods // Include the umbraco Application URL host in the message subject so that // you can identify the site that these results are for. - var umbracoApplicationUrl = ApplicationContext.Current.UmbracoApplicationUrl; - var host = umbracoApplicationUrl; + var host = _runtimeState.ApplicationUrl; - if (Uri.TryCreate(umbracoApplicationUrl, UriKind.Absolute, out var umbracoApplicationUri)) - host = umbracoApplicationUri.Host; - else - LogHelper.Debug($"umbracoApplicationUrl {umbracoApplicationUrl} appears to be invalid"); - - var subject = _textService.Localize("healthcheck/scheduledHealthCheckEmailSubject", new[] { host }); + var subject = _textService.Localize("healthcheck/scheduledHealthCheckEmailSubject", new[] { host.ToString() }); var mailSender = new EmailSender(); using (var mailMessage = CreateMailMessage(subject, message)) diff --git a/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs b/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs index c36b2fded1..e2b174753a 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs @@ -53,7 +53,7 @@ namespace Umbraco.Web.Routing } // Apending any querystring from the incoming request to the redirect url. - url = string.IsNullOrEmpty(contentRequest.Uri.Query) ? url : url + contentRequest.Uri.Query; + url = string.IsNullOrEmpty(frequest.Uri.Query) ? url : url + frequest.Uri.Query; _logger.Debug("Route {Route} matches content {ContentId} with url '{Url}', redirecting.", route, content.Id, url); frequest.SetRedirectPermanent(url);