aboutsummaryrefslogtreecommitdiffstats
path: root/core/Controller/ReferenceApiController.php
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2023-01-27 12:35:44 +0100
committerGitHub <noreply@github.com>2023-01-27 12:35:44 +0100
commita63b5575687bb838c82f86a11a1545668157dc71 (patch)
treeaa0768aeee92df212b2af031a2032c1e906e42bd /core/Controller/ReferenceApiController.php
parent8744029e14f0003f0878a953478c24394687c01a (diff)
parent81c2122ff8214332e2aeca5724b79c565b0979b3 (diff)
downloadnextcloud-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/Controller/ReferenceApiController.php')
-rw-r--r--core/Controller/ReferenceApiController.php30
1 files changed, 29 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]);
+ }
}