fix(folders): enforce videos-only at depth 2 (P1 review fix)

- routes/op.ts: editor / upload / youtube-start reject when folder.parentId === null
- op/folder.ejs: at depth 1 show only "하위 폴더 추가"; at depth 2 show
  "영상 추가" + "플레이리스트 추가". Video grid and sub-folder modal
  rendered conditionally.
- folder.ejs (public): at depth 1 render only sub-folder grid; at depth 2
  render only video grid.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-05-31 23:43:24 +09:00
parent c5faa8808c
commit 3089af1ad8
3 changed files with 69 additions and 56 deletions

View File

@@ -197,6 +197,11 @@ opRouter.get(
res.status(404).send('폴더를 찾을 수 없습니다.')
return
}
// 영상은 2단계(서브) 폴더에만 둔다. 1단계 폴더는 컨테이너 전용.
if (folder.parentId === null) {
res.status(400).send('영상은 하위 폴더에서만 추가할 수 있습니다.')
return
}
const videoId = typeof req.query.id === 'string' ? req.query.id : null
const video = videoId ? getVideo(videoId) : null
res.render('op/editor', {
@@ -239,6 +244,7 @@ opRouter.post(
try {
const folder = getFolderByPath(collectFolderSegments(req.params))
if (!folder) throw new Error('폴더를 찾을 수 없습니다.')
if (folder.parentId === null) throw new Error('영상은 하위 폴더에서만 추가할 수 있습니다.')
const file = req.file
if (!file) throw new Error('파일이 없습니다.')
const title = pickStr(req.body?.title).trim() || file.originalname
@@ -284,6 +290,7 @@ opRouter.post(
try {
const folder = getFolderByPath(collectFolderSegments(req.params))
if (!folder) throw new Error('폴더를 찾을 수 없습니다.')
if (folder.parentId === null) throw new Error('영상은 하위 폴더에서만 추가할 수 있습니다.')
const url = pickStr(req.body.url).trim()
const title = pickStr(req.body.title).trim() || undefined
if (!url) throw new Error('URL 을 입력해 주세요.')