Files
Open-Assistant/website/src/pages/api/admin/user_messages.ts
T
notmd aaa1276bae 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.
2023-02-10 15:16:26 +09:00

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;