fix(chat): handle inactive botid gracefully (#1437)
This commit is contained in:
parent
ad47aa0ee0
commit
314f8ced57
6 changed files with 30 additions and 9 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import { checkBotId } from "botid/server";
|
||||
import { geolocation, ipAddress } from "@vercel/functions";
|
||||
import {
|
||||
convertToModelMessages,
|
||||
|
|
@ -8,6 +7,7 @@ import {
|
|||
stepCountIs,
|
||||
streamText,
|
||||
} from "ai";
|
||||
import { checkBotId } from "botid/server";
|
||||
import { after } from "next/server";
|
||||
import { createResumableStreamContext } from "resumable-stream";
|
||||
import { auth, type UserType } from "@/app/(auth)/auth";
|
||||
|
|
@ -64,9 +64,12 @@ export async function POST(request: Request) {
|
|||
const { id, message, messages, selectedChatModel, selectedVisibilityType } =
|
||||
requestBody;
|
||||
|
||||
const [botResult, session] = await Promise.all([checkBotId(), auth()]);
|
||||
const [botResult, session] = await Promise.all([
|
||||
checkBotId().catch(() => null),
|
||||
auth(),
|
||||
]);
|
||||
|
||||
if (botResult.isBot) {
|
||||
if (botResult?.isBot) {
|
||||
return new ChatbotError("unauthorized:chat").toResponse();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue