diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/RuntimeInformation.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/RuntimeInformation.cs index 284f1cdcb1..77fb040e37 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/RuntimeInformation.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/RuntimeInformation.cs @@ -1,8 +1,9 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Tgstation.Server.Api.Models; -using Tgstation.Server.Host.Core; +using Tgstation.Server.Host.Components.Chat; +using Tgstation.Server.Host.Components.Deployment; using Tgstation.Server.Host.System; namespace Tgstation.Server.Host.Components.Interop.Bridge @@ -30,7 +31,7 @@ namespace Tgstation.Server.Host.Components.Interop.Bridge /// /// The of the owner at the time of launch /// - public string InstanceName { get; } + public string InstanceName { get; set; } /// /// The of the launch @@ -50,31 +51,46 @@ namespace Tgstation.Server.Host.Components.Interop.Bridge /// /// Initializes a new instance of the . /// - /// The to use. - /// The used to set the value of . - /// An used to construct the value of . - /// The s for the . - /// The used to set . - /// The value of . + /// The to use. + /// The to get revision information from. + /// The value of . + /// The value of . /// The value of . + /// The value of . /// The value of . public RuntimeInformation( - IAssemblyInformationProvider assemblyInformationProvider, - IServerPortProvider serverPortProvider, - IEnumerable testMerges, - IEnumerable chatChannels, - Api.Models.Instance instance, - Api.Models.Internal.RevisionInformation revision, + IChatTrackingContext chatTrackingContext, + IDmbProvider dmbProvider, + Version serverVersion, + string instanceName, DreamDaemonSecurity? securityLevel, + ushort serverPort, bool apiValidateOnly) - : base(chatChannels) + : base(chatTrackingContext?.Channels ?? throw new ArgumentNullException(nameof(chatTrackingContext))) { - ServerVersion = assemblyInformationProvider?.Version ?? throw new ArgumentNullException(nameof(assemblyInformationProvider)); - ServerPort = serverPortProvider?.HttpApiPort ?? throw new ArgumentNullException(nameof(serverPortProvider)); - TestMerges = testMerges?.ToList() ?? throw new ArgumentNullException(nameof(testMerges)); - InstanceName = instance?.Name ?? throw new ArgumentNullException(nameof(instance)); - Revision = revision ?? throw new ArgumentNullException(nameof(revision)); + if (dmbProvider == null) + throw new ArgumentNullException(nameof(dmbProvider)); + + ServerVersion = serverVersion ?? throw new ArgumentNullException(nameof(serverVersion)); + + Revision = new Api.Models.Internal.RevisionInformation + { + CommitSha = dmbProvider.CompileJob.RevisionInformation.CommitSha, + OriginCommitSha = dmbProvider.CompileJob.RevisionInformation.OriginCommitSha + }; + + TestMerges = (IReadOnlyCollection)dmbProvider + .CompileJob + .RevisionInformation + .ActiveTestMerges? + .Select(x => x.TestMerge) + .Select(x => new TestMergeInformation(x, Revision)) + .ToList() + ?? Array.Empty(); + + InstanceName = instanceName ?? throw new ArgumentNullException(nameof(instanceName)); SecurityLevel = securityLevel; + ServerPort = serverPort; ApiValidateOnly = apiValidateOnly; } } diff --git a/src/Tgstation.Server.Host/Components/Session/SessionController.cs b/src/Tgstation.Server.Host/Components/Session/SessionController.cs index 5711b7b587..226852fe61 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionController.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionController.cs @@ -458,7 +458,14 @@ namespace Tgstation.Server.Host.Components.Session }; } - response.RuntimeInformation = reattachInformation.RuntimeInformation; + response.RuntimeInformation = new RuntimeInformation( + chatTrackingContext, + reattachInformation.Dmb, + reattachInformation.RuntimeInformation.ServerVersion, + reattachInformation.RuntimeInformation.InstanceName, + reattachInformation.RuntimeInformation.SecurityLevel, + reattachInformation.RuntimeInformation.ServerPort, + reattachInformation.RuntimeInformation.ApiValidateOnly); // Load custom commands chatTrackingContext.CustomCommands = parameters.CustomCommands; @@ -671,7 +678,10 @@ namespace Tgstation.Server.Host.Components.Session /// public Task InstanceRenamed(string newInstanceName, CancellationToken cancellationToken) - => SendCommand(new TopicParameters(newInstanceName), cancellationToken); + { + reattachInformation.RuntimeInformation.InstanceName = newInstanceName; + return SendCommand(new TopicParameters(newInstanceName), cancellationToken); + } /// public Task UpdateChannels(IEnumerable newChannels, CancellationToken cancellationToken) diff --git a/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs b/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs index c6c4483cb0..baf58e1a77 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs @@ -1,7 +1,6 @@ using Microsoft.Extensions.Logging; using System; using System.Globalization; -using System.Linq; using System.Net.Sockets; using System.Text; using System.Threading; @@ -457,31 +456,14 @@ namespace Tgstation.Server.Host.Components.Session IChatTrackingContext chatTrackingContext, DreamDaemonSecurity? securityLevel, bool apiValidateOnly) - { - var revisionInfo = new Api.Models.Internal.RevisionInformation - { - CommitSha = dmbProvider.CompileJob.RevisionInformation.CommitSha, - OriginCommitSha = dmbProvider.CompileJob.RevisionInformation.OriginCommitSha - }; - - var testMerges = dmbProvider - .CompileJob - .RevisionInformation - .ActiveTestMerges? - .Select(x => x.TestMerge) - .Select(x => new TestMergeInformation(x, revisionInfo)) - ?? Enumerable.Empty(); - - return new RuntimeInformation( - assemblyInformationProvider, - serverPortProvider, - testMerges, - chatTrackingContext.Channels, - instance, - revisionInfo, + => new RuntimeInformation( + chatTrackingContext, + dmbProvider, + assemblyInformationProvider.Version, + instance.Name, securityLevel, + serverPortProvider.HttpApiPort, apiValidateOnly); - } /// /// Make sure the BYOND pager is not running.