Files
Umbraco-CMS/src/Umbraco.Core/Services/IServerInformationService.cs
Nikolaj Geisle fc71724386 V14: Server information (#15497)
* Rename information endpoint to troubleshooting

* Rename information endpoint to troubleshooting

* Add new information endpoint

* Fix bad merge

* Add InformationServerController.cs back

* Update serverTime offset to non hard-coded value.

* Add dictionary to swagger models

* Update OpenApi.json file

* Rename map definition

* Add ServerConfigurationBaseModel

* Implement ServerConfigurationBaseModel.cs

* Updated OpenApi

* Updated endpoint to return correct type in openapi

* Use explicit class for server information

* Remove version endpoint, as that is contained in server information.

---------

Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2023-12-22 10:21:11 +01:00

29 lines
1.0 KiB
C#

using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Models;
namespace Umbraco.Cms.Core.Services;
public interface IServerInformationService
{
ServerInformation GetServerInformation();
}
public class ServerInformationService : IServerInformationService
{
private readonly IUmbracoVersion _umbracoVersion;
private readonly TimeProvider _timeProvider;
private RuntimeSettings _runtimeSettings;
public ServerInformationService(IUmbracoVersion umbracoVersion, TimeProvider timeProvider, IOptionsMonitor<RuntimeSettings> runtimeSettingsOptionsMonitor)
{
_umbracoVersion = umbracoVersion;
_timeProvider = timeProvider;
_runtimeSettings = runtimeSettingsOptionsMonitor.CurrentValue;
runtimeSettingsOptionsMonitor.OnChange(runtimeSettings => _runtimeSettings = runtimeSettings);
}
public ServerInformation GetServerInformation() => new(_umbracoVersion.SemanticVersion, _timeProvider.LocalTimeZone, _runtimeSettings.Mode);
}