feat(api,userbot,frontend): add accounts from the web ui and isolate per-account settings
This commit is contained in:
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user