fix: 관리자 이미지 대체 흐름 보정

This commit is contained in:
2026-04-06 10:50:18 +09:00
parent 7164d32ae8
commit a716ee0062
5 changed files with 64 additions and 44 deletions

View File

@@ -822,6 +822,7 @@ router.post('/custom-items/:itemId/replace', requireAdmin, async (req, res) => {
const sourceItem = await findLibraryItemForReplacement(req.params.itemId)
if (!sourceItem?.src) return res.status(404).json({ error: 'source_not_found' })
if (sourceItem.sourceType !== 'user') return res.status(400).json({ error: 'user_item_required' })
const targetItem = await findLibraryItemForReplacement(parsed.data.targetItemId, parsed.data.targetSourceType)
if (!targetItem?.src) return res.status(404).json({ error: 'target_not_found' })
@@ -835,6 +836,10 @@ router.post('/custom-items/:itemId/replace', requireAdmin, async (req, res) => {
toLabel: targetItem.label || '',
})
const sourceCustomItems = await findCustomItemsByIds([sourceItem.id])
await deleteCustomItems([sourceItem.id])
await removeCustomItemFiles(sourceCustomItems)
res.json({
ok: true,
updatedRows: result.updatedRows || 0,