mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-24 21:46:52 +01:00
Fix API things relating to ByondVersion and ByondRights
This commit is contained in:
@@ -25,19 +25,6 @@ namespace Tgstation.Server.Api.Models.Internal
|
||||
[Required]
|
||||
public InstancePermissionSetRights? InstancePermissionSetRights { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Rights.EngineRights"/> of the <see cref="InstancePermissionSet"/>.
|
||||
/// </summary>
|
||||
[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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The legacy <see cref="Rights.EngineRights"/> of the <see cref="InstancePermissionSet"/>.
|
||||
/// </summary>
|
||||
@@ -45,6 +32,12 @@ namespace Tgstation.Server.Api.Models.Internal
|
||||
[Obsolete("Use EngineRights instead")]
|
||||
public EngineRights? ByondRights { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Rights.EngineRights"/> of the <see cref="InstancePermissionSet"/>.
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public EngineRights? EngineRights { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Rights.DreamDaemonRights"/> of the <see cref="InstancePermissionSet"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -20,12 +20,13 @@ namespace Tgstation.Server.Api.Models.Response
|
||||
/// <summary>
|
||||
/// The <see cref="EngineVersion.Version"/> the <see cref="CompileJobResponse"/> was made with.
|
||||
/// </summary>
|
||||
public EngineVersion? ByondVersion { get; set; }
|
||||
[Obsolete("Use EngineVersion instead.")]
|
||||
public string? ByondVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="EngineVersion.Engine"/> the <see cref="CompileJobResponse"/> was made with.
|
||||
/// The <see cref="EngineVersion"/> the <see cref="CompileJobResponse"/> was made with.
|
||||
/// </summary>
|
||||
public EngineType? Engine { get; set; }
|
||||
public EngineVersion? EngineVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The origin <see cref="Uri"/> of the repository the compile job was built from.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -32,7 +32,10 @@ namespace Tgstation.Server.Host.Models
|
||||
/// <inheritdoc />
|
||||
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,
|
||||
|
||||
@@ -73,6 +73,7 @@ namespace Tgstation.Server.Host.Security
|
||||
|
||||
if (right == null)
|
||||
throw new InvalidOperationException("A user right was null!");
|
||||
|
||||
return (ulong)right;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user