feat: align with upstream 1.5.9.9

This commit is contained in:
2026-09-12 18:21:11 +08:00
commit 34f0679117
805 changed files with 376275 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import { and, eq } from 'drizzle-orm'
import { db } from '~/drizzle/db'
import { notifications } from '~/drizzle/schema'
import { SERVER_ERROR_CODES } from '~~/server/config/constants'
import { createApiError } from '~~/server/utils/apiError'
import { createNotificationReadUpdate } from '~~/server/utils/important-notification-policy'
export default defineEventHandler(async (event) => {
const user = event.context.user
if (!user) {
throw createApiError(401, SERVER_ERROR_CODES.NOTIFICATION_AUTH_REQUIRED, '需要登录才能标记通知')
}
try {
const updatedNotifications = await db
.update(notifications)
.set(createNotificationReadUpdate())
.where(
and(
eq(notifications.userId, user.id),
eq(notifications.userDeleted, false),
eq(notifications.read, false)
)
)
.returning({ id: notifications.id })
return {
success: true,
count: updatedNotifications.length
}
} catch (error) {
console.error('标记所有通知失败:', error)
throw createApiError(
500,
SERVER_ERROR_CODES.NOTIFICATION_MARK_READ_FAILED,
'标记所有通知失败'
)
}
})