tests fix

This commit is contained in:
Aadesh Kheria 2026-04-13 12:23:46 -07:00
parent 7a54be90b0
commit ca461d4a26
3 changed files with 18 additions and 3 deletions

View File

@ -39,13 +39,18 @@ export const POST = createSmartRouteHandler({
throw new StatusError(503, "SpacetimeDB unavailable");
}
const authUser = fullReq.auth?.user;
if (!authUser) {
throw new StatusError(StatusError.Unauthorized, "Authentication required");
}
const token = getEnvVariable("STACK_MCP_LOG_TOKEN");
await conn.reducers.addManualQa({
token,
question: body.question,
answer: body.answer,
publish: body.publish,
reviewedBy: fullReq.auth.user.display_name ?? fullReq.auth.user.primary_email ?? fullReq.auth.user.id,
reviewedBy: authUser.display_name ?? authUser.primary_email ?? authUser.id,
});
return {

View File

@ -37,11 +37,16 @@ export const POST = createSmartRouteHandler({
throw new StatusError(503, "SpacetimeDB unavailable");
}
const authUser = fullReq.auth?.user;
if (!authUser) {
throw new StatusError(StatusError.Unauthorized, "Authentication required");
}
const token = getEnvVariable("STACK_MCP_LOG_TOKEN");
await conn.reducers.markHumanReviewed({
token,
correlationId: body.correlationId,
reviewedBy: fullReq.auth.user.display_name ?? fullReq.auth.user.primary_email ?? fullReq.auth.user.id,
reviewedBy: authUser.display_name ?? authUser.primary_email ?? authUser.id,
});
return {

View File

@ -40,6 +40,11 @@ export const POST = createSmartRouteHandler({
throw new StatusError(503, "SpacetimeDB unavailable");
}
const authUser = fullReq.auth?.user;
if (!authUser) {
throw new StatusError(StatusError.Unauthorized, "Authentication required");
}
const token = getEnvVariable("STACK_MCP_LOG_TOKEN");
await conn.reducers.updateHumanCorrection({
token,
@ -47,7 +52,7 @@ export const POST = createSmartRouteHandler({
correctedQuestion: body.correctedQuestion,
correctedAnswer: body.correctedAnswer,
publish: body.publish,
reviewedBy: fullReq.auth.user.display_name ?? fullReq.auth.user.primary_email ?? fullReq.auth.user.id,
reviewedBy: authUser.display_name ?? authUser.primary_email ?? authUser.id,
});
return {