6.3 Wire MQTT publish into FramesController

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-07 15:19:11 +02:00
parent cc0241ab53
commit 948515c9bf
2 changed files with 8 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
using FrameProcessor.Configuration;
using FrameProcessor.Domain;
using FrameProcessor.ImagePipeline;
using FrameProcessor.Mqtt;
using FrameProcessor.Storage;
using Microsoft.AspNetCore.Mvc;
@@ -13,12 +14,14 @@ public sealed class FramesController : ControllerBase
private readonly FramesRegistry _frames;
private readonly IImagePipeline _pipeline;
private readonly ImageStore _store;
private readonly MqttPublisher _mqtt;
public FramesController(FramesRegistry frames, IImagePipeline pipeline, ImageStore store)
public FramesController(FramesRegistry frames, IImagePipeline pipeline, ImageStore store, MqttPublisher mqtt)
{
_frames = frames;
_pipeline = pipeline;
_store = store;
_mqtt = mqtt;
}
[HttpPost("{name}/image")]
@@ -43,13 +46,15 @@ public sealed class FramesController : ControllerBase
await _store.WriteAsync(frame.Mac, pngBytes, cancellationToken).ConfigureAwait(false);
var publishResult = await _mqtt.PublishAsync(frame.Mac, cancellationToken).ConfigureAwait(false);
return Ok(new
{
frame = frame.Name.Value,
mac = frame.Mac.ToString(),
url = $"/i/{frame.Mac}.png",
processedAt = DateTimeOffset.UtcNow,
mqttPublished = false,
mqttPublished = publishResult == PublishResult.Success,
});
}
}