fix: support setting visibility on initial chat creation (#975)
This commit is contained in:
parent
a3221fbcdc
commit
575c12503c
15 changed files with 158 additions and 32 deletions
|
|
@ -49,7 +49,8 @@ export async function POST(request: Request) {
|
|||
}
|
||||
|
||||
try {
|
||||
const { id, message, selectedChatModel } = requestBody;
|
||||
const { id, message, selectedChatModel, selectedVisibilityType } =
|
||||
requestBody;
|
||||
|
||||
const session = await auth();
|
||||
|
||||
|
|
@ -80,7 +81,12 @@ export async function POST(request: Request) {
|
|||
message,
|
||||
});
|
||||
|
||||
await saveChat({ id, userId: session.user.id, title });
|
||||
await saveChat({
|
||||
id,
|
||||
userId: session.user.id,
|
||||
title,
|
||||
visibility: selectedVisibilityType,
|
||||
});
|
||||
} else {
|
||||
if (chat.userId !== session.user.id) {
|
||||
return new Response('Forbidden', { status: 403 });
|
||||
|
|
@ -236,7 +242,7 @@ export async function GET(request: Request) {
|
|||
return new Response('Not found', { status: 404 });
|
||||
}
|
||||
|
||||
if (chat.userId !== session.user.id) {
|
||||
if (chat.visibility === 'private' && chat.userId !== session.user.id) {
|
||||
return new Response('Forbidden', { status: 403 });
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue