0.2.1 onlyoffice修复
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { createSupabaseRouteClient } from "@/lib/supabase/server";
|
||||
import { isConvexEnabled } from "@/lib/convex/enabled";
|
||||
import { requireAuthContext } from "@/lib/auth/authContext";
|
||||
import {
|
||||
buildClientToolKey,
|
||||
resolveClientToolCall,
|
||||
@@ -26,11 +28,26 @@ export async function POST(request: Request) {
|
||||
return NextResponse.json({ error: "缺少 requestId/callId" }, { status: 400 });
|
||||
}
|
||||
|
||||
const supabase = await createSupabaseRouteClient();
|
||||
const {
|
||||
data: { session },
|
||||
} = await supabase.auth.getSession();
|
||||
if (!session) return NextResponse.json({ error: "未登录" }, { status: 401 });
|
||||
const userId = (() => {
|
||||
if (isConvexEnabled()) {
|
||||
const auth = requireAuthContext();
|
||||
return auth.userId;
|
||||
}
|
||||
return null;
|
||||
})();
|
||||
|
||||
const resolvedUserId = async () => {
|
||||
if (userId) return userId;
|
||||
const supabase = await createSupabaseRouteClient();
|
||||
const {
|
||||
data: { session },
|
||||
} = await supabase.auth.getSession();
|
||||
if (!session) return null;
|
||||
return session.user.id;
|
||||
};
|
||||
|
||||
const finalUserId = await resolvedUserId();
|
||||
if (!finalUserId) return NextResponse.json({ error: "未登录" }, { status: 401 });
|
||||
|
||||
const result: ClientToolResult = payload.ok
|
||||
? { ok: true, result: "result" in payload ? payload.result : null }
|
||||
@@ -39,7 +56,7 @@ export async function POST(request: Request) {
|
||||
const key = buildClientToolKey(requestId, callId);
|
||||
const resolved = resolveClientToolCall({
|
||||
key,
|
||||
userId: session.user.id,
|
||||
userId: finalUserId,
|
||||
result,
|
||||
});
|
||||
if (!resolved.ok) {
|
||||
@@ -48,4 +65,3 @@ export async function POST(request: Request) {
|
||||
|
||||
return NextResponse.json({ ok: true });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user