Files
FictionArchive/FictionArchive.Service.NovelService/Consumers/ChapterPullRequestedConsumer.cs
gamer147 ec967770d3
All checks were successful
CI / build-backend (pull_request) Successful in 2m26s
CI / build-frontend (pull_request) Successful in 1m7s
[FA-misc] Saga seems to work, fixed a UserNovelDataService bug
2026-01-28 12:11:06 -05:00

38 lines
1.1 KiB
C#

using FictionArchive.Service.NovelService.Services;
using FictionArchive.Service.Shared.Contracts.Events;
using MassTransit;
using Microsoft.Extensions.Logging;
namespace FictionArchive.Service.NovelService.Consumers;
public class ChapterPullRequestedConsumer : IConsumer<IChapterPullRequested>
{
private readonly ILogger<ChapterPullRequestedConsumer> _logger;
private readonly NovelUpdateService _novelUpdateService;
public ChapterPullRequestedConsumer(
ILogger<ChapterPullRequestedConsumer> logger,
NovelUpdateService novelUpdateService)
{
_logger = logger;
_novelUpdateService = novelUpdateService;
}
public async Task Consume(ConsumeContext<IChapterPullRequested> context)
{
var message = context.Message;
var (chapter, imageCount) = await _novelUpdateService.PullChapterContents(
message.ImportId,
message.NovelId,
message.VolumeId,
message.ChapterOrder);
await context.Publish<IChapterPullCompleted>(new ChapterPullCompleted(
message.ImportId,
chapter.Id,
imageCount
));
}
}