mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-29 16:30:24 +08:00
Complete the handler todo and use withoutRole
This commit is contained in:
@@ -1,23 +1,12 @@
|
||||
import { getToken } from "next-auth/jwt";
|
||||
import { withoutRole } from "src/lib/auth";
|
||||
import { oasstApiClient } from "src/lib/oasst_api_client";
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* Returns the set of valid labels that can be applied to messages.
|
||||
*/
|
||||
const handler = async (req, res) => {
|
||||
const token = await getToken({ req });
|
||||
|
||||
// Return nothing if the user isn't registered.
|
||||
if (!token) {
|
||||
res.status(401).end();
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch the new task.
|
||||
const handler = withoutRole("banned", async (req, res) => {
|
||||
const valid_labels = await oasstApiClient.fetch_valid_text();
|
||||
|
||||
// Send the results to the client.
|
||||
res.status(200).json(valid_labels);
|
||||
};
|
||||
});
|
||||
|
||||
export default handler;
|
||||
|
||||
Reference in New Issue
Block a user