Add from, to, filename and metadatafetcher to ActionRecord DTO

This commit is contained in:
2025-10-16 20:33:56 +02:00
parent ef907ee09d
commit c2b0c0d02b
2 changed files with 51 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using API.Schema.ActionsContext.Actions;
using API.Schema.ActionsContext.Actions.Generic;
// ReSharper disable UnusedAutoPropertyAccessor.Global
namespace API.Controllers.DTOs;
@@ -11,8 +12,12 @@ public sealed record ActionRecord : Identifiable
{
Action = actionRecord.Action;
PerformedAt = actionRecord.PerformedAt;
MangaId = actionRecord is IActionWithMangaRecord m ? m.MangaId : null;
ChapterId = actionRecord is IActionWithChapterRecord c ? c.ChapterId : null;
MangaId = actionRecord is IActionWithMangaRecord manga ? manga.MangaId : null;
ChapterId = actionRecord is IActionWithChapterRecord chapter ? chapter.ChapterId : null;
From = actionRecord is DataMovedActionRecord from ? from.From : null;
To = actionRecord is DataMovedActionRecord to ? to.To : null;
Filename = actionRecord is CoverDownloadedActionRecord filename ? filename.Filename : null;
MetadataFetcher = actionRecord is MetadataUpdatedActionRecord metadata ? metadata.MetadataFetcher : null;
}
/// <summary>
@@ -38,4 +43,28 @@ public sealed record ActionRecord : Identifiable
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? ChapterId { get; init; }
/// <summary>
/// FromPath if Record is <see cref="Schema.ActionsContext.Actions.DataMovedActionRecord"/>
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? From { get; init; }
/// <summary>
/// ToPath if Record is <see cref="Schema.ActionsContext.Actions.DataMovedActionRecord"/>
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? To { get; init; }
/// <summary>
/// Filename if Record is <see cref="Schema.ActionsContext.Actions.CoverDownloadedActionRecord"/>
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Filename { get; init; }
/// <summary>
/// <see cref="Schema.MangaContext.MetadataFetchers.MetadataFetcher"/> if Record is <see cref="Schema.ActionsContext.Actions.MetadataUpdatedActionRecord"/>
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? MetadataFetcher { get; init; }
}

View File

@@ -3285,6 +3285,26 @@
"description": "ChapterId if Record is API.Schema.ActionsContext.Actions.Generic.IActionWithMangaRecord",
"nullable": true
},
"from": {
"type": "string",
"description": "FromPath if Record is API.Schema.ActionsContext.Actions.DataMovedActionRecord",
"nullable": true
},
"to": {
"type": "string",
"description": "ToPath if Record is API.Schema.ActionsContext.Actions.DataMovedActionRecord",
"nullable": true
},
"filename": {
"type": "string",
"description": "Filename if Record is API.Schema.ActionsContext.Actions.CoverDownloadedActionRecord",
"nullable": true
},
"metadataFetcher": {
"type": "string",
"description": "API.Schema.MangaContext.MetadataFetchers.MetadataFetcher if Record is API.Schema.ActionsContext.Actions.MetadataUpdatedActionRecord",
"nullable": true
},
"key": {
"maxLength": 64,
"minLength": 16,