Add attachments to comments
- CommentAttachment link table (comment <-> file) + migration - fileIds in create/update comment; update replaces the whole set, synced in one transaction with the comment - CommentDto.attachments; empty for deleted comments - Soft delete drops attachments so GC can collect the files - Max 10 files per comment, ordered by upload time (uuid v7) - Registers comments as a file owner - Rename CommentAuthorExpanderService -> CommentExpanderService (expands authors and files) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
423afa658d
commit
60fb39f98f
28 files changed
+522
-69
No files matched your search
@@ -1,15 +1,27 @@
|
||||
import { Comment } from '../../domain/entities/comment.entity.js';
|
||||
import { CommentDto } from '../dto/comment.dto.js';
|
||||
import { UserDto } from '../../../user/application/dto/user.dto.js';
|
||||
import { FileDto } from '../../../file/application/dto/file.dto.js';
|
||||
|
||||
export class CommentApplicationMapper {
|
||||
static toDto(comment: Comment, usersById: ReadonlyMap<string, UserDto>): CommentDto {
|
||||
static toDto(
|
||||
comment: Comment,
|
||||
usersById: ReadonlyMap<string, UserDto>,
|
||||
filesById: ReadonlyMap<string, FileDto> = new Map(),
|
||||
): CommentDto {
|
||||
return {
|
||||
id: comment.id as string,
|
||||
issueId: comment.issueId,
|
||||
authorId: comment.authorId,
|
||||
author: comment.authorId ? (usersById.get(comment.authorId) ?? null) : null,
|
||||
content: comment.isDeleted ? null : comment.content,
|
||||
// Файл могли удалить между запросами — такое вложение просто не показываем
|
||||
attachments: comment.isDeleted
|
||||
? []
|
||||
: comment.fileIds.flatMap((fileId) => {
|
||||
const file = filesById.get(fileId);
|
||||
return file ? [file] : [];
|
||||
}),
|
||||
editedAt: comment.editedAt,
|
||||
deletedAt: comment.deletedAt,
|
||||
createdAt: comment.createdAt,
|
||||
|
||||
Reference in new issue
Block a user