diff options
| author | JustZvan <justzvan@justzvan.xyz> | 2026-04-06 15:32:51 +0200 |
|---|---|---|
| committer | JustZvan <justzvan@justzvan.xyz> | 2026-04-06 15:32:51 +0200 |
| commit | 3273e7a0fbbce82f4ce6cacbcdb7b6d6848f6c1b (patch) | |
| tree | 7662ab528c950e5b3605d3f134dc89f399417c8d /api | |
| parent | 7eb8ccae48b0cc18a9dcaa9c3626a02df8e6d919 (diff) | |
feat: gallery scanning preferences
Diffstat (limited to 'api')
| -rw-r--r-- | api/client.ts | 36 | ||||
| -rw-r--r-- | api/controls.ts | 10 | ||||
| -rw-r--r-- | api/types.ts | 4 |
3 files changed, 47 insertions, 3 deletions
diff --git a/api/client.ts b/api/client.ts index 703b1f0..63aa525 100644 --- a/api/client.ts +++ b/api/client.ts @@ -136,9 +136,45 @@ class ApiClient { return result; } + async signInWithGoogle( + idToken: string, + ): Promise<{ success: boolean; token?: string; reason?: string }> { + const result = await this.post<{ + success: boolean; + token: string; + reason: string; + }>("/signin/google", { + idToken, + }); + + if (result.success && result.token) { + await this.setToken(result.token); + } + + return result; + } + async signOut() { await this.clearToken(); } + + async requestPasswordReset( + email: string, + ): Promise<{ success: boolean; reason: string }> { + return this.post<{ success: boolean; reason: string }>("/resetpassword", { + email, + }); + } + + async confirmPasswordReset( + token: string, + password: string, + ): Promise<{ success: boolean; reason: string }> { + return this.post<{ success: boolean; reason: string }>("/resetpassword", { + token, + password, + }); + } } export const apiClient = new ApiClient(); diff --git a/api/controls.ts b/api/controls.ts index 53db7a1..e8c3b02 100644 --- a/api/controls.ts +++ b/api/controls.ts @@ -1,5 +1,5 @@ import { apiClient } from "./client"; -import { ControlsData, SafetyControl } from "./types"; +import { ControlsData, SafetyControl, SafetyControlValue } from "./types"; export async function getControlsData(): Promise<ControlsData> { const deviceId = apiClient.getSelectedDeviceId(); @@ -30,7 +30,7 @@ export async function getControlsData(): Promise<ControlsData> { export async function updateSafetyControl( key: string, - value: boolean + value: SafetyControlValue, ): Promise<void> { const deviceId = apiClient.getSelectedDeviceId(); @@ -97,5 +97,11 @@ function getDefaultControls(): SafetyControl[] { description: "Notify when a new contact is added.", defaultValue: true, }, + { + key: "gallery_scanning_mode", + title: "Gallery scanning", + description: "Scan gallery for inappropriate images", + defaultValue: "none", + }, ]; } diff --git a/api/types.ts b/api/types.ts index 7338d4b..424ccce 100644 --- a/api/types.ts +++ b/api/types.ts @@ -41,11 +41,13 @@ export type Device = { lastCheck: string; }; +export type SafetyControlValue = boolean | string; + export type SafetyControl = { key: string; title: string; description: string; - defaultValue: boolean; + defaultValue: SafetyControlValue; }; export type ControlsData = { |