From 43a9d9c281e36f9640c26acb12be722f632c17ef Mon Sep 17 00:00:00 2001 From: notmd <33456881+notmd@users.noreply.github.com> Date: Tue, 18 Apr 2023 19:54:16 +0700 Subject: [PATCH] fix chat update (#2715) fix #2710 fix #2711 --- website/src/pages/api/chat/hide.ts | 17 ----------------- website/src/pages/api/chat/index.ts | 3 +++ website/src/pages/api/chat/title.ts | 17 ----------------- 3 files changed, 3 insertions(+), 34 deletions(-) delete mode 100644 website/src/pages/api/chat/hide.ts delete mode 100644 website/src/pages/api/chat/title.ts diff --git a/website/src/pages/api/chat/hide.ts b/website/src/pages/api/chat/hide.ts deleted file mode 100644 index ee92debe21..0000000000 --- a/website/src/pages/api/chat/hide.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { withoutRole } from "src/lib/auth"; -import { isChatEnable } from "src/lib/isChatEnable"; -import { createInferenceClient } from "src/lib/oasst_inference_client"; - -const handler = withoutRole("banned", async (req, res, token) => { - if (!isChatEnable()) { - return res.status(404).end(); - } - const client = createInferenceClient(token); - const { chat_id } = req.body as { chat_id: string }; - - await client.update_chat({ chat_id, hidden: true }); - - res.status(200).end(); -}); - -export default handler; diff --git a/website/src/pages/api/chat/index.ts b/website/src/pages/api/chat/index.ts index 1d7aebd888..6fccfdbc83 100644 --- a/website/src/pages/api/chat/index.ts +++ b/website/src/pages/api/chat/index.ts @@ -21,6 +21,9 @@ const handler = withoutRole("banned", async (req, res, token) => { // TODO: re-activate later // await client.delete_chat(req.query.chat_id as string); data = {}; + } else if (req.method === "PUT") { + await client.update_chat(req.body); + return res.status(200).end(); } if (data) { diff --git a/website/src/pages/api/chat/title.ts b/website/src/pages/api/chat/title.ts deleted file mode 100644 index c89f19ae61..0000000000 --- a/website/src/pages/api/chat/title.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { withoutRole } from "src/lib/auth"; -import { isChatEnable } from "src/lib/isChatEnable"; -import { createInferenceClient } from "src/lib/oasst_inference_client"; - -const handler = withoutRole("banned", async (req, res, token) => { - if (!isChatEnable()) { - return res.status(404).end(); - } - const client = createInferenceClient(token); - const { chat_id, title } = req.body as { chat_id: string; title: string }; - - await client.update_chat({ chat_id, title }); - - res.status(200).end(); -}); - -export default handler;