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
+25 -3
View File
@@ -1,4 +1,4 @@
import type { EmojiOp, Message } from "src/types/Conversation";
import type { EmojiOp, FetchUserMessagesCursorResponse, Message } from "src/types/Conversation";
import { LeaderboardReply, LeaderboardTimeFrame } from "src/types/Leaderboard";
import type { AvailableTasks } from "src/types/Task";
import { FetchTrollBoardResponse, TrollboardTimeFrame } from "src/types/Trollboard";
@@ -264,11 +264,33 @@ export class OasstApiClient {
return this.get<Message[]>(`/api/v1/users/${user_id}/messages`);
}
async fetch_user_messages_cursor(
user_id: string,
{
direction,
cursor,
...rest
}: { include_deleted?: boolean; max_count?: number; cursor?: string; direction: "forward" | "back"; desc?: boolean }
) {
return this.get<FetchUserMessagesCursorResponse>(`/api/v1/users/${user_id}/messages/cursor`, {
...rest,
after: direction === "forward" ? cursor : undefined,
before: direction === "back" ? cursor : undefined,
});
}
/**
* Updates the backend's knowledge about the `user_id`.
*/
async set_user_status(user_id: string, is_enabled: boolean, notes: string): Promise<void> {
await this.put(`/api/v1/users/${user_id}?enabled=${is_enabled}&notes=${notes}`);
async set_user_status(
user_id: string,
is_enabled: boolean,
notes: string,
show_on_leaderboard: boolean
): Promise<void> {
await this.put(
`/api/v1/users/${user_id}?enabled=${is_enabled}&notes=${notes}&show_on_leaderboard=${show_on_leaderboard}`
);
}
/**
+3
View File
@@ -0,0 +1,3 @@
export const ROUTES = {
ADMIN_MESSAGE_DETAIL: (id: string) => `/admin/messages/${id}`,
};