From 522af51a8d442990e745134a39019128f6bc9d3e Mon Sep 17 00:00:00 2001 From: Alex Bezdieniezhnykh Date: Tue, 20 May 2025 12:31:18 +0300 Subject: [PATCH] don't send image to the queue on editing --- Azaion.Common/DTO/Queue/AnnotationCreatedMessage.cs | 2 +- Azaion.Common/Services/AnnotationService.cs | 7 +++---- Azaion.Common/Services/FailsafeProducer.cs | 5 ++++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Azaion.Common/DTO/Queue/AnnotationCreatedMessage.cs b/Azaion.Common/DTO/Queue/AnnotationCreatedMessage.cs index 2b2a108..98d3bab 100644 --- a/Azaion.Common/DTO/Queue/AnnotationCreatedMessage.cs +++ b/Azaion.Common/DTO/Queue/AnnotationCreatedMessage.cs @@ -13,7 +13,7 @@ public class AnnotationMessage [Key(3)] public TimeSpan Time { get; set; } [Key(4)] public string ImageExtension { get; set; } = null!; [Key(5)] public string Detections { get; set; } = null!; - [Key(6)] public byte[] Image { get; set; } = null!; + [Key(6)] public byte[]? Image { get; set; } = null!; [Key(7)] public RoleEnum Role { get; set; } [Key(8)] public string Email { get; set; } = null!; [Key(9)] public SourceEnum Source { get; set; } diff --git a/Azaion.Common/Services/AnnotationService.cs b/Azaion.Common/Services/AnnotationService.cs index 63f0ddf..92fc516 100644 --- a/Azaion.Common/Services/AnnotationService.cs +++ b/Azaion.Common/Services/AnnotationService.cs @@ -97,7 +97,7 @@ public class AnnotationService : IAnnotationService, INotificationHandler>(msg.Detections) ?? [], msg.Source, - new MemoryStream(msg.Image), + msg.Image == null ? null : new MemoryStream(msg.Image), msg.Role, msg.Email, fromQueue: true, @@ -141,9 +141,8 @@ public class AnnotationService : IAnnotationService, INotificationHandler Validated -> stream: azaion-annotations-confirm - // AI, Manual save from Operators -> Created -> stream: azaion-annotations - private async Task SaveAnnotationInner(DateTime createdDate, string originalMediaName, TimeSpan time, List detections, SourceEnum source, Stream? stream, + private async Task SaveAnnotationInner(DateTime createdDate, string originalMediaName, TimeSpan time, + List detections, SourceEnum source, Stream? stream, RoleEnum userRole, string createdEmail, bool fromQueue = false, diff --git a/Azaion.Common/Services/FailsafeProducer.cs b/Azaion.Common/Services/FailsafeProducer.cs index 4a2d877..5beafc1 100644 --- a/Azaion.Common/Services/FailsafeProducer.cs +++ b/Azaion.Common/Services/FailsafeProducer.cs @@ -98,7 +98,10 @@ public class FailsafeAnnotationsProducer if (annotation == null) continue; - var image = await File.ReadAllBytesAsync(annotation.ImagePath, ct); + var image = record.Operation == AnnotationStatus.Created + ? await File.ReadAllBytesAsync(annotation.ImagePath, ct) + : null; + var annMessage = new AnnotationMessage { Name = annotation.Name,