AI Newsletter Digest improvements: fixed QP soft line break decoding, URL extraction, and content cleaning
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { prisma } from '@/lib/db/prisma'
|
||||
import { getCurrentUser } from '@/lib/auth'
|
||||
import { canAccessWorkspace } from '@/lib/db/workspace-access'
|
||||
|
||||
// POST /api/workspaces/[id]/handoff-notes/[noteId]/acknowledge
|
||||
export async function POST(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string; noteId: string } }
|
||||
) {
|
||||
try {
|
||||
const user = await getCurrentUser()
|
||||
if (!user) {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
const { id: workspaceId, noteId } = params
|
||||
const access = await canAccessWorkspace(user.id, workspaceId)
|
||||
if (!access) {
|
||||
return NextResponse.json({ error: 'Forbidden' }, { status: 403 })
|
||||
}
|
||||
|
||||
// Get current note
|
||||
const note = await prisma.handoffNote.findUnique({
|
||||
where: { id: noteId }
|
||||
})
|
||||
|
||||
if (!note) {
|
||||
return NextResponse.json({ error: 'Note not found' }, { status: 404 })
|
||||
}
|
||||
|
||||
// Add user to acknowledged list if not already there
|
||||
const acknowledgedBy = note.acknowledgedBy || []
|
||||
if (!acknowledgedBy.includes(user.id)) {
|
||||
acknowledgedBy.push(user.id)
|
||||
|
||||
await prisma.handoffNote.update({
|
||||
where: { id: noteId },
|
||||
data: { acknowledgedBy }
|
||||
})
|
||||
}
|
||||
|
||||
return NextResponse.json({ success: true })
|
||||
} catch (error) {
|
||||
console.error('Failed to acknowledge note:', error)
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to acknowledge note' },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user