Add video attachments to chat messages

- browser uploads the source straight to MinIO via presigned PUT (type and
  exact size are signed, up to 100 MB); upload is confirmed once by its owner
- message is created with a PROCESSING video, transcoded in the background
  (chatVideoExecutor): H.264/AAC, short side up to 720px, faststart,
  metadata (incl. location) stripped, poster frame; up to 60 s
- the updated message is re-broadcast over WebSocket when READY or FAILED;
  stuck processing is failed after 30 min
- message_attachments: status, poster_key, duration_ms, processing_started_at
- chat deletion and orphan cleanup handle video posters; rate limit chat-video

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SlimusMinus
2026-10-28 23:00:11 +03:00
parent 648886c25e
commit 871b16a038
25 changed files with 1151 additions and 52 deletions

View File

@@ -32,6 +32,7 @@ class OrphanFileCleanupServiceTest {
S3Object.builder().key("avatars/legacy.jpg").lastModified(old).build(),
S3Object.builder().key("orphan.jpg").lastModified(old).build(),
S3Object.builder().key("chat/5/photo.jpg").lastModified(old).build(),
S3Object.builder().key("chat/5/video-poster.jpg").lastModified(old).build(),
S3Object.builder().key("chat/5/deleted-chat.jpg").lastModified(old).build(),
S3Object.builder().key("fresh.jpg").lastModified(Instant.now()).build()).build();
when(s3.listObjectsV2Paginator(any(ListObjectsV2Request.class)))
@@ -46,6 +47,7 @@ class OrphanFileCleanupServiceTest {
when(users.findAllAvatarUrls()).thenReturn(List.of("http://minio:9010/refound-images/avatars/legacy.jpg?x=1"));
MessageAttachmentRepository attachments = mock(MessageAttachmentRepository.class);
when(attachments.findAllObjectKeys()).thenReturn(List.of("chat/5/photo.jpg"));
when(attachments.findAllPosterKeys()).thenReturn(List.of("chat/5/video-poster.jpg"));
FileStorageService storage = mock(FileStorageService.class);
new OrphanFileCleanupService(s3, properties, images, users, attachments, storage, true, Duration.ofHours(24), 100)
@@ -57,6 +59,7 @@ class OrphanFileCleanupServiceTest {
verify(storage, never()).deleteFile("fresh.jpg");
// Фото чата живёт, пока на него ссылается вложение; файл удалённого чата — сирота
verify(storage, never()).deleteFile("chat/5/photo.jpg");
verify(storage, never()).deleteFile("chat/5/video-poster.jpg");
verify(storage).deleteFile("chat/5/deleted-chat.jpg");
}