Adds the consumptions API endpoints, their summaries and documnetation

This commit is contained in:
BinaryAlley committed 2026-10-24 22:02:32 +03:00
1 parent bc65e35de7
commit c27621818c
24 files changed
+2200 -4

No files matched your search

@@ -4,6 +4,7 @@ using Lumina.Application.Common.Utilities;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Linq;
#endregion
namespace Lumina.Application.Core.MediaConsumption.Commands.StartConsumption;
@@ -28,13 +29,13 @@ public class StartConsumptionCommandValidator : AbstractValidator<StartConsumpti
.When(command => command.LibraryId is not null && command.LibraryId.Length > 0)
.WithError(Errors.Library.LibraryIdCannotBeEmpty);
// Validates the kind of media that is consumed, taken from the route. Kinds that are not supported by the current catalogues are rejected by the handler, because that is a business rule.
// Validates the kind of media that is consumed, taken from the route. Only the member names are accepted, so a numeric route value that happens to parse as an enumeration value is rejected. Kinds that are not supported by the current catalogues are rejected by the handler, because that is a business rule.
RuleFor(command => command.MediaKind)
.NotEmpty()
.WithError(Errors.MediaConsumption.UnsupportedMediaKind);
RuleFor(command => command.MediaKind)
.Must(mediaKind => Enum.TryParse<MediaKind>(mediaKind, ignoreCase: true, out MediaKind parsedMediaKind) && Enum.IsDefined(parsedMediaKind))
.Must(mediaKind => Enum.GetNames<MediaKind>().Contains(mediaKind, StringComparer.OrdinalIgnoreCase))
.When(command => command.MediaKind is not null && command.MediaKind.Length > 0)
.WithError(Errors.MediaConsumption.UnsupportedMediaKind);
@@ -76,6 +76,10 @@ public class GetResumePointQueryHandler : IQueryHandler<GetResumePointQuery, Res
return DomainErrors.MediaConsumption.UnsupportedMediaKind;
if (!ruleResult.Value.CanResume)
return DomainErrors.MediaConsumption.MediaKindCannotResume;
// A planned kind cannot have a resume point, because its catalogue does not exist yet and start rejects it. Report it as unsupported instead of
// as a missing resume point, so the response does not imply that the kind is usable.
if (!ruleResult.Value.IsSupportedByCurrentCatalogues)
return DomainErrors.MediaConsumption.UnsupportedMediaKind;
// The resume point is read without tracking and scoped to the current user, so a resume point of another user is indistinguishable from a missing one.
Result<MediaResumePointEntity?> getResumePointResult = await _unitOfWork.MediaResumePointRepository
@@ -4,6 +4,7 @@ using Lumina.Application.Common.Utilities;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Linq;
#endregion
namespace Lumina.Application.Core.MediaConsumption.Queries.GetResumePoint;
@@ -18,13 +19,13 @@ public class GetResumePointQueryValidator : AbstractValidator<GetResumePointQuer
/// </summary>
public GetResumePointQueryValidator()
{
// Validates the kind of media to resume, taken from the route.
// Validates the kind of media to resume, taken from the route. Only the member names are accepted, so a numeric route value that happens to parse as an enumeration value is rejected.
RuleFor(query => query.MediaKind)
.NotEmpty()
.WithError(Errors.MediaConsumption.UnsupportedMediaKind);
RuleFor(query => query.MediaKind)
.Must(mediaKind => Enum.TryParse(mediaKind, ignoreCase: true, out MediaKind parsedMediaKind) && Enum.IsDefined(parsedMediaKind))
.Must(mediaKind => Enum.GetNames<MediaKind>().Contains(mediaKind, StringComparer.OrdinalIgnoreCase))
.When(query => query.MediaKind is not null && query.MediaKind.Length > 0)
.WithError(Errors.MediaConsumption.UnsupportedMediaKind);