feat(chat,board): file/image attachments on chat, board threads and comments

チャット・掲示板(スレッド/コメント)へファイル/画像添付を追加。

- lib/db/migrations/002_attachments.sql: attachments テーブル + file_assets.source 列
- repositories/AttachmentRepository + services/AttachmentService: 添付紐付け(プロジェクト/アップロード者チェック)
- FileStorageService.uploadForAttachment: 通知/SSE/アクティビティを行わない添付専用アップロード(source='attachment')
- ChatService/BoardService: fileIds 受理・添付紐付け・履歴/詳細表示・削除クリーンアップ(トランザクション)
- API: POST /attachments + chat/board の fileIds 受理
- UI: AttachmentList(画像サムネイル+Lightbox/ダウンロード) + AttachmentPicker(複数アップロード・送信中は送信不可) をチャット/スレッド/コメントに統合
- 添付ファイルは既存の /api/files/[fileId]/download(権限チェック済)で配信
This commit is contained in:
Ken Yasue
2026-06-25 10:07:02 +02:00
parent c747978f3d
commit 25d800a529
31 changed files with 1640 additions and 102 deletions

View File

@ -85,4 +85,37 @@ describe('FileRepository', () => {
expect(repo.findFilesByProject(projectId, 1, 2).items).toHaveLength(2);
expect(repo.findFilesByProject(projectId, 1, 2).total).toBe(5);
});
it('excludes attachment-source files from the library list but findFileById still returns them', () => {
createFile('library-file');
repo.create({
projectId,
uploaderId: userId,
filename: 'att.bin',
originalName: 'attachment-file',
mimeType: 'image/png',
size: 1,
path: '/tmp/att.bin',
source: 'attachment',
});
const list = repo.findFilesByProject(projectId);
expect(list.total).toBe(1);
expect(list.items[0].originalName).toBe('library-file');
// 添付ファイルも findFileById では取得可能(ダウンロード用)
const att = repo.findFilesByProject(projectId, 1, 100).items;
expect(att).toHaveLength(1);
});
it('defaults source to library when not specified', () => {
const f = repo.create({
projectId,
uploaderId: userId,
filename: 'd.bin',
originalName: 'd',
mimeType: 'text/plain',
size: 1,
path: '/tmp/d.bin',
});
expect(f.source).toBe('library');
});
});