feat(songs): 歌曲管理支持批量驳回、投稿留言自动审查与排期范围可见性过滤
- 新增 /api/admin/songs/batch-reject.post 批量驳回接口(事务清排期/投票/扣接纳数/黑名单去重/异步通知) - requireSongAdmin 三角色校验 + createApiError 统一错误包装 - scheduleDaysBefore/After 四字段排期可见范围限制(开放 API 与公开排期接口三处缓存路径 + DB 条件过滤) - submissionNoteAutoModeration 基于黑名单 KEYWORD/LANGUAGE/GENRE 自动判定留言 publicStatus,命中自动关闭 submissionNotePublic - 更新 songs/request.post 与 songs/[id]/update.put 接入自动审查逻辑
This commit is contained in:
@@ -3,6 +3,7 @@ import { db } from '~/drizzle/db'
|
||||
import { users } from '~/drizzle/schema'
|
||||
import { executeRedisCommand, isRedisReady } from '../../utils/redis'
|
||||
import { eq } from 'drizzle-orm'
|
||||
import { isSessionRevokedByJti, touchAuthSession } from '~~/server/utils/create-auth-session'
|
||||
|
||||
// 用户认证缓存(永久缓存,登出或权限变更时主动失效)
|
||||
|
||||
@@ -19,9 +20,17 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
|
||||
// 验证JWT令牌
|
||||
const decoded = jwt.verify(token, process.env.JWT_SECRET!) as { userId: number }
|
||||
const decoded = jwt.verify(token, process.env.JWT_SECRET!) as { userId: number; jti?: string }
|
||||
const userId = decoded.userId
|
||||
|
||||
if (await isSessionRevokedByJti(decoded.jti)) {
|
||||
throw createError({
|
||||
statusCode: 401,
|
||||
statusMessage: '会话已撤销,请重新登录'
|
||||
})
|
||||
}
|
||||
touchAuthSession(decoded.jti).catch(() => undefined)
|
||||
|
||||
// 优先从Redis缓存获取用户认证状态
|
||||
if (isRedisReady()) {
|
||||
const cachedUser = await executeRedisCommand(async () => {
|
||||
|
||||
Reference in New Issue
Block a user