From 3273e7a0fbbce82f4ce6cacbcdb7b6d6848f6c1b Mon Sep 17 00:00:00 2001 From: JustZvan Date: Mon, 6 Apr 2026 15:32:51 +0200 Subject: feat: gallery scanning preferences --- api/client.ts | 36 ++++++++++++++++++++++++++++++++++++ api/controls.ts | 10 ++++++++-- api/types.ts | 4 +++- 3 files changed, 47 insertions(+), 3 deletions(-) (limited to 'api') 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 { const deviceId = apiClient.getSelectedDeviceId(); @@ -30,7 +30,7 @@ export async function getControlsData(): Promise { export async function updateSafetyControl( key: string, - value: boolean + value: SafetyControlValue, ): Promise { 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 = { -- cgit v1.2.3