Add basic personalizatoin (#868)

This commit is contained in:
Siddharth Ganesan
2025-08-04 17:35:28 -07:00
committed by GitHub
parent 1035aca71e
commit b613010a26

View File

@@ -1,6 +1,7 @@
import { and, desc, eq } from 'drizzle-orm'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import { getSession } from '@/lib/auth'
import {
authenticateCopilotRequestSessionOnly,
createBadRequestResponse,
@@ -125,14 +126,15 @@ export async function POST(req: NextRequest) {
const tracker = createRequestTracker()
try {
// Authenticate user using consolidated helper
const { userId: authenticatedUserId, isAuthenticated } =
await authenticateCopilotRequestSessionOnly()
// Get session to access user information including name
const session = await getSession()
if (!isAuthenticated || !authenticatedUserId) {
if (!session?.user?.id) {
return createUnauthorizedResponse()
}
const authenticatedUserId = session.user.id
const body = await req.json()
const {
message,
@@ -242,6 +244,7 @@ export async function POST(req: NextRequest) {
stream: stream,
streamToolCalls: true,
mode: mode,
...(createNewChat && session?.user?.name && { userName: session.user.name }),
}),
})