feat: add CLI message center commands

This commit is contained in:
gitea committed 2026-09-05 14:05:05 +08:00
1 parent 0be1365289
commit 621c8cb7dc
11 files changed
+242 -4

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
import type { KyInstance } from "ky";
import type { MessageQueryOptions } from "./types.js";
export async function fetchMessagePage(
client: KyInstance,
corpId: string,
options: MessageQueryOptions = {}
): Promise<{ count: number; items: Record<string, unknown>[] }> {
const start = options.start ?? 0;
const count = options.count ?? 20;
const read = options.read ?? false;
const response = await client.get("api/message/v1/messages", {
searchParams: {
read: String(read),
start: String(start),
count: String(count),
corpId,
},
});
const json = (await response.json()) as { count?: number; items?: Record<string, unknown>[] };
return { count: json.count ?? json.items?.length ?? 0, items: json.items ?? [] };
}
export async function markMessageRead(client: KyInstance, corpId: string, messageId: string): Promise<void> {
// The downstream route accepts the compound ID with its colon separators intact.
await client.put(`api/message/v1/messages/$${messageId}`, {
searchParams: { corpId },
json: { id: messageId },
});
}