From f847bc8a0aff2568c23f048f31547a7362f78409 Mon Sep 17 00:00:00 2001 From: Guy Van Sanden Date: Thu, 16 Apr 2026 20:54:35 +0200 Subject: [PATCH] v1.0.43 - use OCS controller --- appinfo/info.xml | 2 +- appinfo/routes.php | 2 +- js/minimalprofile.js | 16 ++++++++-------- lib/Controller/ApiController.php | 7 +++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 4939b5a..7f283a1 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -4,7 +4,7 @@ Minimal Profile Hides profile fields to create a minimal user profile Allows administrators to hide profile fields like pronouns, social links, etc. - 1.0.42 + 1.0.43 AGPL Your Name MinimalProfile diff --git a/appinfo/routes.php b/appinfo/routes.php index e553cf8..517d5bb 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -1,6 +1,6 @@ [ + 'ocs' => [ ['name' => 'api#getHiddenFields', 'url' => '/api/v1/hidden-fields', 'verb' => 'GET'], ], ]; \ No newline at end of file diff --git a/js/minimalprofile.js b/js/minimalprofile.js index ea2f1f9..cd42d99 100644 --- a/js/minimalprofile.js +++ b/js/minimalprofile.js @@ -1,5 +1,5 @@ /** - * MinimalProfile v41 - API-based config + * MinimalProfile v42 - OCS API */ (function() { 'use strict'; @@ -8,7 +8,7 @@ return; } - console.log('MinimalProfile v41: Starting'); + console.log('MinimalProfile v42: Starting'); var map = { 'pronouns': '#account-property-pronouns', @@ -36,22 +36,22 @@ function loadConfig() { var xhr = new XMLHttpRequest(); - xhr.open('GET', '/apps/minimalprofile/api/v1/hidden-fields', true); + xhr.open('GET', '/ocs/v2.php/apps/minimalprofile/api/v1/hidden-fields', true); xhr.onload = function() { if (xhr.status === 200) { try { var data = JSON.parse(xhr.responseText); - console.log('MinimalProfile v41: API returned', data.hiddenFields); - hideFields(data.hiddenFields); + console.log('MinimalProfile v42: API returned', data.ocs.data.hiddenFields); + hideFields(data.ocs.data.hiddenFields); } catch(e) { - console.error('MinimalProfile v41: JSON parse error', e); + console.error('MinimalProfile v42: JSON parse error', e); } } else { - console.error('MinimalProfile v41: API failed', xhr.status); + console.error('MinimalProfile v42: API failed', xhr.status); } }; xhr.onerror = function() { - console.error('MinimalProfile v41: Network error'); + console.error('MinimalProfile v42: Network error'); }; xhr.send(); } diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index 4aabb41..93fe7b6 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -4,21 +4,20 @@ declare(strict_types=1); namespace OCA\MinimalProfile\Controller; -use OCP\AppFramework\Controller; use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\Attribute\PublicPage; use OCP\AppFramework\Http\JSONResponse; +use OCP\AppFramework\OCSController; use OCP\IConfig; use OCP\IRequest; -class ApiController extends Controller { +class ApiController extends OCSController { public function __construct( - string $appName, IRequest $request, private IConfig $config, ) { - parent::__construct($appName, $request); + parent::__construct('minimalprofile', $request); } #[NoCSRFRequired]