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:
@@ -0,0 +1,72 @@
|
||||
export const NOTIFICATION_TITLE_MAX_LENGTH = 200
|
||||
export const NOTIFICATION_CONTENT_MAX_LENGTH = 20000
|
||||
export const NOTIFICATION_SOURCES = {
|
||||
SYSTEM: 'SYSTEM',
|
||||
ADMIN_MANUAL: 'ADMIN_MANUAL'
|
||||
} as const
|
||||
|
||||
export type NotificationSenderInput = {
|
||||
id: number
|
||||
name?: string | null
|
||||
username?: string | null
|
||||
}
|
||||
|
||||
export type NotificationSenderSnapshot = {
|
||||
senderId: number | null
|
||||
senderName: string | null
|
||||
senderUsername: string | null
|
||||
}
|
||||
|
||||
export const resolveNotificationSource = (sender: NotificationSenderInput | null) =>
|
||||
sender ? NOTIFICATION_SOURCES.ADMIN_MANUAL : NOTIFICATION_SOURCES.SYSTEM
|
||||
|
||||
export const createNotificationSenderSnapshot = (
|
||||
sender: NotificationSenderInput | null = null
|
||||
): NotificationSenderSnapshot => ({
|
||||
senderId: sender?.id ?? null,
|
||||
senderName: sender?.name?.trim() || null,
|
||||
senderUsername: sender?.username?.trim() || null
|
||||
})
|
||||
|
||||
export const serializeNotificationSender = (snapshot: NotificationSenderSnapshot) =>
|
||||
snapshot.senderId
|
||||
? {
|
||||
id: snapshot.senderId,
|
||||
name: snapshot.senderName,
|
||||
username: snapshot.senderUsername
|
||||
}
|
||||
: null
|
||||
|
||||
export const shouldCheckImportantNotification = (
|
||||
authenticated: boolean,
|
||||
userId?: number | null,
|
||||
requirePasswordChange = false
|
||||
): boolean =>
|
||||
authenticated && Number.isInteger(userId) && Number(userId) > 0 && !requirePasswordChange
|
||||
|
||||
export const canSendSystemNotification = (role?: string): boolean =>
|
||||
role === 'ADMIN' || role === 'SUPER_ADMIN'
|
||||
|
||||
export const resolveImportantFlag = (value: unknown): boolean | null => {
|
||||
if (value === undefined) return false
|
||||
return typeof value === 'boolean' ? value : null
|
||||
}
|
||||
|
||||
export const shouldDeliverSystemNotification = (
|
||||
important: boolean,
|
||||
notificationsEnabled?: boolean
|
||||
): boolean => important || notificationsEnabled !== false
|
||||
|
||||
export const shouldRetainNotificationHistory = (type: string, source: string): boolean =>
|
||||
type === 'SYSTEM_NOTICE' && source === NOTIFICATION_SOURCES.ADMIN_MANUAL
|
||||
|
||||
export const createNotificationReadUpdate = (updatedAt = new Date()) => ({
|
||||
read: true as const,
|
||||
updatedAt
|
||||
})
|
||||
|
||||
export const createNotificationUserDeleteUpdate = (updatedAt = new Date()) => ({
|
||||
userDeleted: true as const,
|
||||
read: true as const,
|
||||
updatedAt
|
||||
})
|
||||
Reference in New Issue
Block a user