feat(api,userbot,frontend): add accounts from the web ui and isolate per-account settings
This commit is contained in:
1 parent
92fd20137e
commit
9c265af3d3
19 files changed
+917
-268
No files matched your search
@@ -14,6 +14,7 @@ import type {
|
||||
JobStatus,
|
||||
JobView,
|
||||
LinkView,
|
||||
LoginState,
|
||||
MediaVersion,
|
||||
MediaView,
|
||||
MessageAt,
|
||||
@@ -45,6 +46,41 @@ export function listAccounts(): Promise<Account[]> {
|
||||
return request<Account[]>("/accounts");
|
||||
}
|
||||
|
||||
export function startLogin(phone: string): Promise<LoginState> {
|
||||
return request<LoginState>("/accounts/login", {
|
||||
method: "POST",
|
||||
body: { phone },
|
||||
});
|
||||
}
|
||||
|
||||
export function submitLoginCode(
|
||||
loginId: string,
|
||||
code: string
|
||||
): Promise<LoginState> {
|
||||
return request<LoginState>(`/accounts/login/${loginId}/code`, {
|
||||
method: "POST",
|
||||
body: { code },
|
||||
});
|
||||
}
|
||||
|
||||
export function submitLoginPassword(
|
||||
loginId: string,
|
||||
password: string
|
||||
): Promise<LoginState> {
|
||||
return request<LoginState>(`/accounts/login/${loginId}/password`, {
|
||||
method: "POST",
|
||||
body: { password },
|
||||
});
|
||||
}
|
||||
|
||||
export function cancelLogin(loginId: string): Promise<void> {
|
||||
return request<void>(`/accounts/login/${loginId}`, { method: "DELETE" });
|
||||
}
|
||||
|
||||
export function logoutAccount(accountId: number): Promise<void> {
|
||||
return request<void>(`/accounts/${accountId}`, { method: "DELETE" });
|
||||
}
|
||||
|
||||
export function listChats(page: Page = {}): Promise<Chat[]> {
|
||||
return request<Chat[]>("/chats", { account: true, query: { ...page } });
|
||||
}
|
||||
@@ -70,6 +106,7 @@ export function updatePolicy(
|
||||
): Promise<PolicyRecord> {
|
||||
return request<PolicyRecord>(`/policy/${id}`, {
|
||||
method: "PUT",
|
||||
account: true,
|
||||
body: toggles,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,6 +22,14 @@ export interface Account {
|
||||
tg_user_id: number | null;
|
||||
}
|
||||
|
||||
export type LoginStage = "code" | "password" | "done";
|
||||
|
||||
export interface LoginState {
|
||||
account: Account | null;
|
||||
login_id: string;
|
||||
stage: LoginStage;
|
||||
}
|
||||
|
||||
export interface Chat {
|
||||
chat_id: number;
|
||||
has_avatar: boolean;
|
||||
|
||||
Reference in new issue
Block a user