Admin user management (#1393)

part of #1022

    Allow updating the show_on_leaderboard field.
    Add raw JSON of the user object.
    Add a new user message table.
    Also fixed style issue: hard to see reaction count when the user also reacted.
    Rename MessageTable to MessageConversation.
This commit is contained in:
notmd
2023-02-10 15:16:26 +09:00
committed by GitHub
parent 4ab5f58c88
commit aaa1276bae
26 changed files with 409 additions and 135 deletions
+14 -4
View File
@@ -1,15 +1,25 @@
import { withRole } from "src/lib/auth";
import { createApiClient } from "src/lib/oasst_client_factory";
import type { Message } from "src/types/Conversation";
const LIMIT = 10;
/**
* Returns the messages recorded by the backend for a user.
*/
const handler = withRole("admin", async (req, res, token) => {
const { user } = req.query;
const { cursor, direction, user } = req.query;
const oasstApiClient = await createApiClient(token);
const messages: Message[] = await oasstApiClient.fetch_user_messages(user as string);
res.status(200).json(messages);
const response = await oasstApiClient.fetch_user_messages_cursor(user as string, {
include_deleted: true,
direction: direction as "back",
cursor: cursor as string,
max_count: LIMIT,
desc: true,
});
res.status(200).json(response);
});
export default handler;