ConusAI vendor 81941888f
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
'use server'
|
||||
|
||||
import { revalidatePath } from 'next/cache'
|
||||
import { fileRepository } from '@/entities/file'
|
||||
import { noteId } from '@/entities/note'
|
||||
import { audit, blob, db } from '@/shared/api'
|
||||
import { ensureVisitor } from '@/shared/lib/visitor-session'
|
||||
|
||||
/** Remove an attachment the visitor attached: its row first, then its stored bytes. */
|
||||
export async function deleteFile(id: string): Promise<void> {
|
||||
const key = noteId.parse(id)
|
||||
const actor = await ensureVisitor()
|
||||
const removed = await fileRepository(db()).remove(key, actor)
|
||||
if (!removed) return
|
||||
await blob().del(removed.url)
|
||||
await audit().log('file.deleted', { actor: { kind: 'human', id: actor }, target: { id: key } })
|
||||
revalidatePath('/')
|
||||
}
|
||||
Reference in New Issue
Block a user