From 0ca70d809133e6f1a4106e5a633dc02bfc0bd223 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 21 Oct 2023 05:18:16 -0400 Subject: [PATCH] Fix API things relating to ByondVersion and ByondRights --- .../Models/Internal/InstancePermissionSet.cs | 19 ++++++------------- .../Models/Response/CompileJobResponse.cs | 7 ++++--- .../InstancePermissionSetController.cs | 8 ++++++-- .../Models/CompileJob.cs | 5 ++++- .../Models/InstancePermissionSet.cs | 5 ++++- .../Security/AuthenticationContext.cs | 1 + 6 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/Tgstation.Server.Api/Models/Internal/InstancePermissionSet.cs b/src/Tgstation.Server.Api/Models/Internal/InstancePermissionSet.cs index 94ec3c5246..0081d79e8f 100644 --- a/src/Tgstation.Server.Api/Models/Internal/InstancePermissionSet.cs +++ b/src/Tgstation.Server.Api/Models/Internal/InstancePermissionSet.cs @@ -25,19 +25,6 @@ namespace Tgstation.Server.Api.Models.Internal [Required] public InstancePermissionSetRights? InstancePermissionSetRights { get; set; } - /// - /// The of the . - /// - [NotMapped] - [JsonIgnore] - public EngineRights? EngineRights - { -#pragma warning disable CS0618 // Type or member is obsolete - get => ByondRights; - set => ByondRights = value; -#pragma warning restore CS0618 // Type or member is obsolete - } - /// /// The legacy of the . /// @@ -45,6 +32,12 @@ namespace Tgstation.Server.Api.Models.Internal [Obsolete("Use EngineRights instead")] public EngineRights? ByondRights { get; set; } + /// + /// The of the . + /// + [NotMapped] + public EngineRights? EngineRights { get; set; } + /// /// The of the . /// diff --git a/src/Tgstation.Server.Api/Models/Response/CompileJobResponse.cs b/src/Tgstation.Server.Api/Models/Response/CompileJobResponse.cs index b38f11dcc0..0ad0283749 100644 --- a/src/Tgstation.Server.Api/Models/Response/CompileJobResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/CompileJobResponse.cs @@ -20,12 +20,13 @@ namespace Tgstation.Server.Api.Models.Response /// /// The the was made with. /// - public EngineVersion? ByondVersion { get; set; } + [Obsolete("Use EngineVersion instead.")] + public string? ByondVersion { get; set; } /// - /// The the was made with. + /// The the was made with. /// - public EngineType? Engine { get; set; } + public EngineVersion? EngineVersion { get; set; } /// /// The origin of the repository the compile job was built from. diff --git a/src/Tgstation.Server.Host/Controllers/InstancePermissionSetController.cs b/src/Tgstation.Server.Host/Controllers/InstancePermissionSetController.cs index 381cae1bc7..1428871208 100644 --- a/src/Tgstation.Server.Host/Controllers/InstancePermissionSetController.cs +++ b/src/Tgstation.Server.Host/Controllers/InstancePermissionSetController.cs @@ -93,7 +93,9 @@ namespace Tgstation.Server.Host.Controllers var dbUser = new InstancePermissionSet { - EngineRights = RightsHelper.Clamp(model.EngineRights ?? EngineRights.None), +#pragma warning disable CS0618 // Type or member is obsolete + EngineRights = RightsHelper.Clamp(model.EngineRights ?? model.ByondRights ?? EngineRights.None), +#pragma warning restore CS0618 // Type or member is obsolete ChatBotRights = RightsHelper.Clamp(model.ChatBotRights ?? ChatBotRights.None), ConfigurationRights = RightsHelper.Clamp(model.ConfigurationRights ?? ConfigurationRights.None), DreamDaemonRights = RightsHelper.Clamp(model.DreamDaemonRights ?? DreamDaemonRights.None), @@ -138,7 +140,9 @@ namespace Tgstation.Server.Host.Controllers if (originalPermissionSet == null) return this.Gone(); - originalPermissionSet.EngineRights = RightsHelper.Clamp(model.EngineRights ?? originalPermissionSet.EngineRights.Value); +#pragma warning disable CS0618 // Type or member is obsolete + originalPermissionSet.ByondRights = RightsHelper.Clamp(model.EngineRights ?? model.ByondRights ?? originalPermissionSet.EngineRights.Value); +#pragma warning restore CS0618 // Type or member is obsolete originalPermissionSet.RepositoryRights = RightsHelper.Clamp(model.RepositoryRights ?? originalPermissionSet.RepositoryRights.Value); originalPermissionSet.InstancePermissionSetRights = RightsHelper.Clamp(model.InstancePermissionSetRights ?? originalPermissionSet.InstancePermissionSetRights.Value); originalPermissionSet.ChatBotRights = RightsHelper.Clamp(model.ChatBotRights ?? originalPermissionSet.ChatBotRights.Value); diff --git a/src/Tgstation.Server.Host/Models/CompileJob.cs b/src/Tgstation.Server.Host/Models/CompileJob.cs index 7f69e618ff..4b43fd049c 100644 --- a/src/Tgstation.Server.Host/Models/CompileJob.cs +++ b/src/Tgstation.Server.Host/Models/CompileJob.cs @@ -90,7 +90,10 @@ namespace Tgstation.Server.Host.Models Job = Job.ToApi(), Output = Output, RevisionInformation = RevisionInformation.ToApi(), - ByondVersion = Api.Models.Internal.EngineVersion.TryParse(ByondVersion, out var version) +#pragma warning disable CS0618 // Type or member is obsolete + ByondVersion = ByondVersion, +#pragma warning restore CS0618 // Type or member is obsolete + EngineVersion = Api.Models.Internal.EngineVersion.TryParse(ByondVersion, out var version) ? version : throw new InvalidOperationException($"Failed to parse BYOND version: {ByondVersion}"), MinimumSecurityLevel = MinimumSecurityLevel, diff --git a/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs b/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs index 623e920734..c4436bd795 100644 --- a/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs +++ b/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs @@ -32,7 +32,10 @@ namespace Tgstation.Server.Host.Models /// public InstancePermissionSetResponse ToApi() => new InstancePermissionSetResponse { - EngineRights = EngineRights, +#pragma warning disable CS0618 // Type or member is obsolete + ByondRights = ByondRights, + EngineRights = ByondRights, +#pragma warning restore CS0618 // Type or member is obsolete ChatBotRights = ChatBotRights, ConfigurationRights = ConfigurationRights, DreamDaemonRights = DreamDaemonRights, diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs index 105c7f9837..1b19fc46d3 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs @@ -73,6 +73,7 @@ namespace Tgstation.Server.Host.Security if (right == null) throw new InvalidOperationException("A user right was null!"); + return (ulong)right; } }