mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-29 16:30:24 +08:00
aaa1276bae
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.
26 lines
648 B
TypeScript
26 lines
648 B
TypeScript
import { withRole } from "src/lib/auth";
|
|
import { createApiClient } from "src/lib/oasst_client_factory";
|
|
|
|
const LIMIT = 10;
|
|
|
|
/**
|
|
* Returns the messages recorded by the backend for a user.
|
|
*/
|
|
const handler = withRole("admin", async (req, res, token) => {
|
|
const { cursor, direction, user } = req.query;
|
|
|
|
const oasstApiClient = await createApiClient(token);
|
|
|
|
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;
|