@@ -57,6 +57,7 @@ import { updateTag } from "next/cache";
5757import { headers } from "next/headers" ;
5858import type { NextResponse } from "next/server" ;
5959
60+ import { logAuditEvent } from "@/lib/server/audit" ;
6061import type { UserRole } from "@/lib/server/auth-verify" ;
6162import { authVerify } from "@/lib/server/auth-verify" ;
6263import { verifyToken } from "@/lib/server/captcha" ;
@@ -1305,6 +1306,7 @@ export async function updateOwnFriendLink(
13051306 } ,
13061307 select : {
13071308 id : true ,
1309+ name : true ,
13081310 status : true ,
13091311 } ,
13101312 } ) ;
@@ -1398,6 +1400,7 @@ export async function deleteOwnFriendLink(
13981400 } ,
13991401 select : {
14001402 id : true ,
1403+ name : true ,
14011404 status : true ,
14021405 } ,
14031406 } ) ;
@@ -1427,6 +1430,29 @@ export async function deleteOwnFriendLink(
14271430
14281431 invalidateFriendLinkCache ( ) ;
14291432
1433+ await logAuditEvent ( {
1434+ user : {
1435+ uid : String ( user . uid ) ,
1436+ } ,
1437+ details : {
1438+ action : "DELETE" ,
1439+ resourceType : "FRIEND_LINK" ,
1440+ resourceId : String ( current . id ) ,
1441+ value : {
1442+ old : {
1443+ id : current . id ,
1444+ name : current . name ,
1445+ ownerId : user . uid ,
1446+ } ,
1447+ new : null ,
1448+ } ,
1449+ description : `用户删除了友链「${ current . name } 」` ,
1450+ metadata : {
1451+ id : current . id ,
1452+ } ,
1453+ } ,
1454+ } ) ;
1455+
14301456 return response . ok ( {
14311457 message : "友链记录已删除" ,
14321458 data : {
@@ -1844,6 +1870,30 @@ export async function deleteFriendLinkByAdmin(
18441870 ) ;
18451871 }
18461872
1873+ await logAuditEvent ( {
1874+ user : {
1875+ uid : String ( admin . uid ) ,
1876+ } ,
1877+ details : {
1878+ action : "DELETE" ,
1879+ resourceType : "FRIEND_LINK" ,
1880+ resourceId : String ( current . id ) ,
1881+ value : {
1882+ old : {
1883+ id : current . id ,
1884+ name : current . name ,
1885+ ownerId : current . ownerId ,
1886+ } ,
1887+ new : null ,
1888+ } ,
1889+ description : `管理员删除了友链「${ current . name } 」` ,
1890+ metadata : {
1891+ id : current . id ,
1892+ ownerId : current . ownerId || 0 ,
1893+ } ,
1894+ } ,
1895+ } ) ;
1896+
18471897 return response . ok ( {
18481898 message : "友链记录已删除" ,
18491899 data : {
0 commit comments