Files
im_webapp/web/src/lib/api/bootstrap.ts
T

50 lines
1.6 KiB
TypeScript

import { imGet } from './client';
export interface MessagePolicy {
supported_actions?: string[];
edit_window_seconds?: number;
recall_window_seconds?: number;
}
/** README §2.1's "固定置顶两项" -- topic names are fixed/well-known on this backend (confirmed:
* docs/IM-前后端对接文档.md:909, `file_assistant.topic:"slf"`, `system_messages.topic:"sys"`), not
* per-user values the client has to discover another way. */
interface BootstrapEntry {
enabled: boolean;
route: string;
topic?: string;
unread_count: number;
/** e.g. "topic" (file_assistant) vs "business" (system_messages) -- which side actually owns the
* unread count above, confirmed live but not consumed by anything yet. */
unread_source?: string;
}
export interface BootstrapConfig {
message_policy?: MessagePolicy;
limits?: { max_forward_targets?: number; [key: string]: unknown };
features?: Record<string, boolean>;
permissions?: Record<string, boolean>;
modules?: unknown;
workbench_version?: unknown;
entries?: {
new_friends?: BootstrapEntry;
groups?: BootstrapEntry;
file_assistant?: BootstrapEntry;
system_messages?: BootstrapEntry;
};
entry_badges?: {
new_friends_pending_count?: number;
groups_unread_count?: number;
file_assistant_unread_count?: number;
system_unread_count?: number;
workbench_total_unread?: number;
contacts_total_unread?: number;
};
system_topic?: { topic: string; type: string };
[key: string]: unknown;
}
export function getBootstrap() {
return imGet<BootstrapConfig>('/bootstrap');
}