diff options
author | Julius Härtl <jus@bitgrid.net> | 2023-01-27 12:35:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-27 12:35:44 +0100 |
commit | a63b5575687bb838c82f86a11a1545668157dc71 (patch) | |
tree | aa0768aeee92df212b2af031a2032c1e906e42bd /core | |
parent | 8744029e14f0003f0878a953478c24394687c01a (diff) | |
parent | 81c2122ff8214332e2aeca5724b79c565b0979b3 (diff) | |
download | nextcloud-server-a63b5575687bb838c82f86a11a1545668157dc71.tar.gz nextcloud-server-a63b5575687bb838c82f86a11a1545668157dc71.zip |
Merge pull request #35557 from nextcloud/enh/31667/extend-reference-api-for-frontend-picker
Diffstat (limited to 'core')
-rw-r--r-- | core/Controller/ReferenceApiController.php | 30 | ||||
-rw-r--r-- | core/routes.php | 2 |
2 files changed, 31 insertions, 1 deletions
diff --git a/core/Controller/ReferenceApiController.php b/core/Controller/ReferenceApiController.php index 266532113d8..6aba56d7e77 100644 --- a/core/Controller/ReferenceApiController.php +++ b/core/Controller/ReferenceApiController.php @@ -25,15 +25,21 @@ declare(strict_types=1); namespace OC\Core\Controller; use OCP\AppFramework\Http\DataResponse; +use OCP\Collaboration\Reference\IDiscoverableReferenceProvider; use OCP\Collaboration\Reference\IReferenceManager; use OCP\IRequest; class ReferenceApiController extends \OCP\AppFramework\OCSController { private IReferenceManager $referenceManager; + private ?string $userId; - public function __construct(string $appName, IRequest $request, IReferenceManager $referenceManager) { + public function __construct(string $appName, + IRequest $request, + IReferenceManager $referenceManager, + ?string $userId) { parent::__construct($appName, $request); $this->referenceManager = $referenceManager; + $this->userId = $userId; } /** @@ -88,4 +94,26 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { 'references' => array_filter($result) ]); } + + /** + * @NoAdminRequired + */ + public function getProvidersInfo(): DataResponse { + $providers = $this->referenceManager->getDiscoverableProviders(); + $jsonProviders = array_map(static function (IDiscoverableReferenceProvider $provider) { + return $provider->jsonSerialize(); + }, $providers); + return new DataResponse($jsonProviders); + } + + /** + * @NoAdminRequired + */ + public function touchProvider(string $providerId, ?int $timestamp = null): DataResponse { + if ($this->userId !== null) { + $success = $this->referenceManager->touchProvider($this->userId, $providerId, $timestamp); + return new DataResponse(['success' => $success]); + } + return new DataResponse(['success' => false]); + } } diff --git a/core/routes.php b/core/routes.php index a3fdfafd7bf..dcf8e4024af 100644 --- a/core/routes.php +++ b/core/routes.php @@ -134,6 +134,8 @@ $application->registerRoutes($this, [ ['root' => '/references', 'name' => 'ReferenceApi#resolveOne', 'url' => '/resolve', 'verb' => 'GET'], ['root' => '/references', 'name' => 'ReferenceApi#extract', 'url' => '/extract', 'verb' => 'POST'], ['root' => '/references', 'name' => 'ReferenceApi#resolve', 'url' => '/resolve', 'verb' => 'POST'], + ['root' => '/references', 'name' => 'ReferenceApi#getProvidersInfo', 'url' => '/providers', 'verb' => 'GET'], + ['root' => '/references', 'name' => 'ReferenceApi#touchProvider', 'url' => '/provider/{providerId}', 'verb' => 'PUT'], ['root' => '/profile', 'name' => 'ProfileApi#setVisibility', 'url' => '/{targetUserId}', 'verb' => 'PUT'], |