chenpei 7326e273e1 fix: harden media upload and release safety
Protect upload cleanup and atomic completion paths, add durable media worker leases and brand asset validation, and introduce verified migration/bootstrap/deployment gates.
2026-08-12 18:04:08 +08:00

35 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { NextResponse } from 'next/server'
import { getServerSession } from 'next-auth'
import { authOptions } from '@/lib/auth'
import { hasSystemAdminPermission } from '@/lib/department-permission'
/**
* 旧版在线恢复接口曾把历史桶地址直接写回新素材记录。
*
* 该流程无法保证对象已经迁移到当前存储桶,也没有逐条清单、备份和回滚,
* 因此永久停用。历史恢复必须改用默认 dry-run、显式来源和显式目标的离线脚本,
* 并在写库前先完成对象迁移与可读性校验。
*/
export async function POST() {
const session = await getServerSession(authOptions)
if (!session?.user) {
return NextResponse.json({ error: '请先登录' }, { status: 401 })
}
const sessionUser = session.user as {
role?: string | null
isSuperAdmin?: boolean
}
if (!hasSystemAdminPermission(sessionUser.role, Boolean(sessionUser.isSuperAdmin))) {
return NextResponse.json({ error: '仅系统管理员可执行数据恢复' }, { status: 403 })
}
return NextResponse.json(
{
error: '在线历史恢复接口已停用',
action: '请使用经过清单确认、默认 dry-run 且先迁移对象再写库的离线恢复流程',
},
{ status: 410 },
)
}