Skip to content

Commit

Permalink
Add setting to enable facial recognition for all users by default.
Browse files Browse the repository at this point in the history
The default philosophy is that users must enable facial recognition
with their personal data, but in certain scenarios you may prefer to
enable it by default, for example to the family.
  • Loading branch information
matiasdelellis committed May 31, 2024
1 parent d3f10aa commit 2af9189
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/Service/SettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class SettingsService {
const CURRENT_MODEL_KEY = 'model';
const FALLBACK_CURRENT_MODEL = -1;

/* Enabling facial recognition for users */
const DEFAULT_USER_ENABLED_KEY = 'default_enabled';
const DEFAULT_USER_ENABLED = 'false';

/* Assigned memory for image processing */
const ASSIGNED_MEMORY_KEY = 'assigned_memory';
const MINIMUM_ASSIGNED_MEMORY = (1 * 1024 * 1024 * 1024) * 2.0 / 3.0;
Expand Down Expand Up @@ -83,7 +87,7 @@ class SettingsService {

/** User setting what indicates if has the analysis enabled */
const USER_ENABLED_KEY = 'enabled';
const DEFAULT_USER_ENABLED = 'false';
// The default is defined by system 'default_enabled' key

/** User setting that remember last images checked */
const STALE_IMAGES_LAST_CHECKED_KEY = 'stale_images_last_checked';
Expand Down Expand Up @@ -170,7 +174,8 @@ public function __construct(IConfig $config,
* @param null|string $userId
*/
public function getUserEnabled (?string $userId = null): bool {
$enabled = $this->config->getUserValue($userId ?? $this->userId, Application::APP_NAME, self::USER_ENABLED_KEY, self::DEFAULT_USER_ENABLED);
$enabled = $this->config->getUserValue($userId ?? $this->userId, Application::APP_NAME, self::USER_ENABLED_KEY,
$this->getDefaultUserEnabled());
return ($enabled === 'true');
}

Expand Down Expand Up @@ -302,6 +307,11 @@ public function setMinimumFacesInCluster($no_faces): void {
* The next settings are advanced preferences that are not available in gui.
* See: https://github.com/matiasdelellis/facerecognition/wiki/Settings#hidden-settings
*/
public function getDefaultUserEnabled (): bool {
$enabled = $this->config->getAppValue(Application::APP_NAME, self::USER_DEFAULT_ENABLED_KEY, self::DEFAULT_USER_ENABLED);
return ($enabled === 'true');
}

public function getHandleSharedFiles(): bool {
$handle = $this->config->getAppValue(Application::APP_NAME, self::HANDLE_SHARED_FILES_KEY, self::DEFAULT_HANDLE_SHARED_FILES);
return ($handle === 'true');
Expand Down

0 comments on commit 2af9189

Please sign in to comment.