feat(audit): change audit log action to string at db level and split file/folder actions

This commit is contained in:
yiling
2026-08-01 14:49:08 +08:00
parent 6d80f06c22
commit 5ef7716c9c
19 changed files with 192 additions and 193 deletions
+16 -1
View File
@@ -3,7 +3,8 @@ import { zValidator } from '@hono/zod-validator'
import { postAttachmentRequestSchema } from '@shumai/dtos'
import { assetService } from '@shumai/core/src/asset/asset'
import { s3Service } from '@shumai/core/src/s3/s3'
import { AssetType } from '@shumai/db'
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
import { AssetType, AuditAction, prisma } from '@shumai/db'
import { ulid } from 'ulid'
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
import type { Prisma } from '@shumai/db'
@@ -37,6 +38,20 @@ const route = new Hono<{ Variables: { user: User } }>().post(
creatorId: user.id,
})
const proj = await prisma.project.findUnique({
where: { id: projectId },
select: { teamId: true },
})
if (proj) {
await auditLogService.logAction({
action: AuditAction.file_create,
teamId: proj.teamId,
userId: user.id,
projectId,
itemId: assetInfo.id,
})
}
const uploadUrl = await s3Service.presign(process.env.S3_BUCKET || 'shumai', key, 'PUT')
return c.json({