aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Controller/ReferenceApiController.php30
-rw-r--r--core/routes.php2
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'],