admin: detect recognize installed but not enabled (fix #789)

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/803/head
Varun Patil 2023-08-24 21:14:41 -07:00
parent 68cdcffb8d
commit b0bf05df31
6 changed files with 36 additions and 17 deletions

View File

@ -83,8 +83,9 @@ class OtherController extends GenericApiController
'places_gis' => Util::getSystemConfig('memories.gis_type'),
'systemtags_enabled' => Util::tagsIsEnabled(),
'recognize_enabled' => Util::recognizeIsEnabled(),
'albums_enabled' => Util::albumsIsEnabled(),
'recognize_installed' => Util::recognizeIsInstalled(),
'recognize_enabled' => Util::recognizeIsEnabled(),
'facerecognition_installed' => Util::facerecognitionIsInstalled(),
'facerecognition_enabled' => Util::facerecognitionIsEnabled(),
'preview_generator_enabled' => Util::previewGeneratorIsEnabled(),

View File

@ -84,6 +84,23 @@ class Util
* Check if recognize is enabled for this user.
*/
public static function recognizeIsEnabled(): bool
{
if (!self::recognizeIsInstalled()) {
return false;
}
$config = \OC::$server->get(IAppConfig::class);
if ('true' !== $config->getValue('recognize', 'faces.enabled', 'false')) {
return false;
}
return true;
}
/**
* Check if recognize is installed.
*/
public static function recognizeIsInstalled(): bool
{
$appManager = \OC::$server->get(IAppManager::class);
@ -96,11 +113,6 @@ class Util
return false;
}
$c = \OC::$server->get(IAppConfig::class);
if ('true' !== $c->getValue('recognize', 'faces.enabled', 'false')) {
return false;
}
return true;
}
@ -109,16 +121,21 @@ class Util
*/
public static function facerecognitionIsEnabled(): bool
{
if (!self::facerecognitionIsInstalled()) {
return false;
}
try {
$uid = self::getUID();
} catch (\Exception $e) {
return false;
}
$config = \OC::$server->get(IConfig::class);
$e = $config->getUserValue($uid, 'facerecognition', 'enabled', 'false');
$enabled = \OC::$server->get(IConfig::class)
->getUserValue($uid, 'facerecognition', 'enabled', 'false')
;
return 'true' === $e;
return 'true' === $enabled;
}
/**

View File

@ -168,7 +168,7 @@ export default defineComponent({
return false;
}
if (this.config.facerecognition_enabled) {
if (this.config.facerecognition_installed) {
return t('memories', 'People (Recognize)');
}

View File

@ -13,11 +13,10 @@
<NcNoteCard :type="sconfig.recognize_enabled ? 'success' : 'warning'">
{{
sconfig.recognize_enabled
? t('memories', 'Recognize is installed and enabled.')
: t(
'memories',
'Recognize is not installed. Some features like face recognition and object tagging may be unavailable.'
)
? t('memories', 'Recognize is installed and enabled for face recognition.')
: sconfig.recognize_installed
? t('memories', 'Recognize is installed but not enabled for face recognition.')
: t('memories', 'Recognize is not installed. Face recognition and object tagging may be unavailable.')
}}
</NcNoteCard>
<NcNoteCard v-if="sconfig.facerecognition_installed" type="success">

View File

@ -103,8 +103,9 @@ class StaticConfig {
places_gis: -1,
systemtags_enabled: false,
recognize_enabled: false,
albums_enabled: false,
recognize_installed: false,
recognize_enabled: false,
facerecognition_installed: false,
facerecognition_enabled: false,
preview_generator_enabled: false,

View File

@ -236,8 +236,9 @@ export type IConfig = {
places_gis: number;
systemtags_enabled: boolean;
recognize_enabled: boolean;
albums_enabled: boolean;
recognize_installed: boolean;
recognize_enabled: boolean;
facerecognition_installed: boolean;
facerecognition_enabled: boolean;
preview_generator_enabled: boolean;