mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-08-06 12:50:42 +08:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user