mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-07-20 12:10:50 +08:00
Send x-oasst-user header
This commit is contained in:
@@ -1,19 +1,21 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { withoutRole } from "src/lib/auth";
|
||||
import { oasstApiClient } from "src/lib/oasst_api_client";
|
||||
import { createApiClient } from "src/lib/oasst_api_client";
|
||||
import prisma from "src/lib/prismadb";
|
||||
|
||||
const handler = withoutRole("banned", async (req, res) => {
|
||||
const handler = withoutRole("banned", async (req, res, token) => {
|
||||
// Parse out the local task ID and the interaction contents.
|
||||
const { id: frontendId, reason } = req.body;
|
||||
|
||||
const registeredTask = await prisma.registeredTask.findUniqueOrThrow({ where: { id: frontendId } });
|
||||
const [oasstApiClient, registeredTask] = await Promise.all([
|
||||
createApiClient(token),
|
||||
prisma.registeredTask.findUniqueOrThrow({ where: { id: frontendId } }),
|
||||
]);
|
||||
|
||||
const task = registeredTask.task as Prisma.JsonObject;
|
||||
const id = task.id as string;
|
||||
const taskId = (registeredTask.task as Prisma.JsonObject).id as string;
|
||||
|
||||
// Update the backend with the rejection
|
||||
await oasstApiClient.nackTask(id, reason);
|
||||
await oasstApiClient.nackTask(taskId, reason);
|
||||
|
||||
// Send the results to the client.
|
||||
res.status(200).json({});
|
||||
|
||||
Reference in New Issue
Block a user