AI Newsletter Digest improvements: fixed QP soft line break decoding, URL extraction, and content cleaning

This commit is contained in:
Krilly
2026-03-04 13:29:22 +00:00
parent 29a98137a7
commit 57dd294675
13706 changed files with 2114953 additions and 237629 deletions

View File

@@ -0,0 +1,54 @@
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]/care-tasks/[taskId]/complete
export async function POST(
request: NextRequest,
{ params }: { params: { id: string; taskId: string } }
) {
try {
const user = await getCurrentUser()
if (!user) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
}
const { id: workspaceId, taskId } = params
const access = await canAccessWorkspace(user.id, workspaceId)
if (!access || access.role === 'VIEWER') {
return NextResponse.json({ error: 'Forbidden' }, { status: 403 })
}
const task = await prisma.careTask.update({
where: { id: taskId },
data: {
completedAt: new Date(),
completedById: user.id
},
include: {
completedBy: { select: { id: true, name: true } }
}
})
// Log audit
await prisma.auditLog.create({
data: {
workspaceId,
userId: user.id,
action: 'COMPLETE_TASK',
entityType: 'CARE_TASK',
entityId: task.id,
details: { title: task.title }
}
})
return NextResponse.json({ task })
} catch (error) {
console.error('Failed to complete task:', error)
return NextResponse.json(
{ error: 'Failed to complete task' },
{ status: 500 }
)
}
}