Refactored container helper service. Cleaned up event models. Implemented version changing. Added security questions before rebuild

This commit is contained in:
2026-01-29 11:23:07 +01:00
parent 97a676ccd7
commit e1207b8d9b
15 changed files with 242 additions and 55 deletions

View File

@@ -2,7 +2,7 @@
namespace Moonlight.Shared.Http.Events;
public struct RebuildEvent
public struct RebuildEventDto
{
[JsonPropertyName("type")]
public RebuildEventType Type { get; set; }

View File

@@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Http.Requests.Admin.ContainerHelper;
public class SetVersionDto
{
[Required]
[RegularExpression(@"^(?!\/|.*\/\/|.*\.\.|.*\/$)[A-Za-z0-9._/-]+$", ErrorMessage = "Invalid version format")]
public string Version { get; set; }
}

View File

@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using System.Text.Json;
using System.Text.Json.Serialization;
using Moonlight.Shared.Http.Events;
using Moonlight.Shared.Http.Requests.ApiKeys;
using Moonlight.Shared.Http.Requests.Roles;
@@ -46,13 +47,28 @@ namespace Moonlight.Shared.Http;
[JsonSerializable(typeof(ThemeDto))]
// Events
[JsonSerializable(typeof(RebuildEvent))]
[JsonSerializable(typeof(RebuildEventDto))]
// Container Helper
[JsonSerializable(typeof(ContainerHelperStatusDto))]
// Misc
[JsonSerializable(typeof(ProblemDetails))]
public partial class SerializationContext : JsonSerializerContext
public partial class SharedSerializationContext : JsonSerializerContext
{
private static JsonSerializerOptions? InternalTunedOptions;
public static JsonSerializerOptions TunedOptions
{
get
{
if (InternalTunedOptions != null)
return InternalTunedOptions;
InternalTunedOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web);
InternalTunedOptions.TypeInfoResolverChain.Add(Default);
return InternalTunedOptions;
}
}
}