feat(frontend): capture policy shows what each rule changes, rule card opens from folder and chat menus and can trash downloaded files, trash is paged
This commit is contained in:
1 parent
f646f29ff9
commit
cb01d7dff8
16 files changed
+1536
-369
No files matched your search
@@ -26,13 +26,17 @@ import type {
|
||||
PolicyChatKind,
|
||||
PolicyCreate,
|
||||
PolicyRecord,
|
||||
PolicyRule,
|
||||
PolicyScope,
|
||||
PresenceHourly,
|
||||
PresenceSample,
|
||||
ReactionView,
|
||||
ResponseStats,
|
||||
ScopeTarget,
|
||||
SearchHit,
|
||||
StorageFile,
|
||||
StorageGroupName,
|
||||
StorageScope,
|
||||
StorageSummary,
|
||||
StoryView,
|
||||
TrashItem,
|
||||
@@ -148,6 +152,23 @@ export function deletePolicy(id: number): Promise<void> {
|
||||
return request<void>(`/policy/${id}`, { method: "DELETE" });
|
||||
}
|
||||
|
||||
function scopeQuery(target: ScopeTarget): Record<string, number> {
|
||||
return "chatId" in target
|
||||
? { chat_id: target.chatId }
|
||||
: { folder_id: target.folderId };
|
||||
}
|
||||
|
||||
export function getPolicyOverview(): Promise<PolicyRule[]> {
|
||||
return request<PolicyRule[]>("/policy/overview", { account: true });
|
||||
}
|
||||
|
||||
export function getPolicyScope(target: ScopeTarget): Promise<PolicyScope> {
|
||||
return request<PolicyScope>("/policy/scope", {
|
||||
account: true,
|
||||
query: scopeQuery(target),
|
||||
});
|
||||
}
|
||||
|
||||
export function effectivePolicy(query: {
|
||||
chat_id: number;
|
||||
is_bot?: boolean;
|
||||
@@ -601,8 +622,25 @@ export function getStorageFiles(
|
||||
});
|
||||
}
|
||||
|
||||
export function getTrash(): Promise<TrashItem[]> {
|
||||
return request<TrashItem[]>("/storage/trash", { account: true });
|
||||
export function getTrash(page: Page = {}): Promise<TrashItem[]> {
|
||||
return request<TrashItem[]>("/storage/trash", {
|
||||
account: true,
|
||||
query: { ...page },
|
||||
});
|
||||
}
|
||||
|
||||
export function getStorageScope(target: ScopeTarget): Promise<StorageScope> {
|
||||
return request<StorageScope>("/storage/scope", {
|
||||
account: true,
|
||||
query: scopeQuery(target),
|
||||
});
|
||||
}
|
||||
|
||||
export function trashScope(target: ScopeTarget): Promise<TrashOutcome> {
|
||||
return request<TrashOutcome>("/storage/trash/scope", {
|
||||
body: { account_id: accounts.selectedId, ...scopeQuery(target) },
|
||||
method: "POST",
|
||||
});
|
||||
}
|
||||
|
||||
export function moveToTrash(mediaIds: number[]): Promise<TrashOutcome> {
|
||||
@@ -612,7 +650,7 @@ export function moveToTrash(mediaIds: number[]): Promise<TrashOutcome> {
|
||||
});
|
||||
}
|
||||
|
||||
export function restoreFromTrash(keys: string[]): Promise<TrashOutcome> {
|
||||
export function restoreFromTrash(keys: string[] | null): Promise<TrashOutcome> {
|
||||
return request<TrashOutcome>("/storage/trash/restore", {
|
||||
body: { account_id: accounts.selectedId, keys },
|
||||
method: "POST",
|
||||
|
||||
@@ -423,6 +423,24 @@ export interface PolicyRecord extends CaptureToggles {
|
||||
scope_type: PolicyScopeType;
|
||||
}
|
||||
|
||||
export interface PolicyParent {
|
||||
scope_id: number | null;
|
||||
scope_type: PolicyScopeType;
|
||||
title: string | null;
|
||||
toggles: CaptureToggles;
|
||||
}
|
||||
|
||||
export interface PolicyRule extends PolicyRecord {
|
||||
parent: PolicyParent | null;
|
||||
title: string | null;
|
||||
}
|
||||
|
||||
export interface PolicyScope {
|
||||
parent: PolicyParent | null;
|
||||
rule: PolicyRecord | null;
|
||||
title: string | null;
|
||||
}
|
||||
|
||||
export type PolicyChatKind = "dm" | "group" | "channel";
|
||||
|
||||
export interface PolicyCreate extends CaptureToggles {
|
||||
@@ -613,3 +631,13 @@ export interface TrashOutcome {
|
||||
files: number;
|
||||
keys: string[];
|
||||
}
|
||||
|
||||
export interface StorageScope {
|
||||
bytes: number;
|
||||
chats: number;
|
||||
files: number;
|
||||
gone: number;
|
||||
kept: number;
|
||||
}
|
||||
|
||||
export type ScopeTarget = { chatId: number } | { folderId: number };
|
||||
Reference in new issue
Block a user