|
|
|
@ -12,6 +12,8 @@ use OC\Core\ResponseDefinitions; |
|
|
|
|
use OCP\AppFramework\Http; |
|
|
|
|
use OCP\AppFramework\Http\Attribute\AnonRateLimit; |
|
|
|
|
use OCP\AppFramework\Http\Attribute\ApiRoute; |
|
|
|
|
use OCP\AppFramework\Http\Attribute\NoAdminRequired; |
|
|
|
|
use OCP\AppFramework\Http\Attribute\PublicPage; |
|
|
|
|
use OCP\AppFramework\Http\DataResponse; |
|
|
|
|
use OCP\Collaboration\Reference\IDiscoverableReferenceProvider; |
|
|
|
|
use OCP\Collaboration\Reference\IReferenceManager; |
|
|
|
@ -35,8 +37,6 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @NoAdminRequired |
|
|
|
|
* |
|
|
|
|
* Extract references from a text |
|
|
|
|
* |
|
|
|
|
* @param string $text Text to extract from |
|
|
|
@ -46,6 +46,7 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
* |
|
|
|
|
* 200: References returned |
|
|
|
|
*/ |
|
|
|
|
#[NoAdminRequired] |
|
|
|
|
#[ApiRoute(verb: 'POST', url: '/extract', root: '/references')] |
|
|
|
|
public function extract(string $text, bool $resolve = false, int $limit = 1): DataResponse { |
|
|
|
|
$references = $this->referenceManager->extractReferences($text); |
|
|
|
@ -66,8 +67,6 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @PublicPage |
|
|
|
|
* |
|
|
|
|
* Extract references from a text |
|
|
|
|
* |
|
|
|
|
* @param string $text Text to extract from |
|
|
|
@ -79,6 +78,7 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
* 200: References returned |
|
|
|
|
*/ |
|
|
|
|
#[ApiRoute(verb: 'POST', url: '/extractPublic', root: '/references')] |
|
|
|
|
#[PublicPage] |
|
|
|
|
#[AnonRateLimit(limit: 10, period: 120)] |
|
|
|
|
public function extractPublic(string $text, string $sharingToken, bool $resolve = false, int $limit = 1): DataResponse { |
|
|
|
|
$references = $this->referenceManager->extractReferences($text); |
|
|
|
@ -99,8 +99,6 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @NoAdminRequired |
|
|
|
|
* |
|
|
|
|
* Resolve a reference |
|
|
|
|
* |
|
|
|
|
* @param string $reference Reference to resolve |
|
|
|
@ -108,6 +106,7 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
* |
|
|
|
|
* 200: Reference returned |
|
|
|
|
*/ |
|
|
|
|
#[NoAdminRequired] |
|
|
|
|
#[ApiRoute(verb: 'GET', url: '/resolve', root: '/references')] |
|
|
|
|
public function resolveOne(string $reference): DataResponse { |
|
|
|
|
/** @var ?CoreReference $resolvedReference */ |
|
|
|
@ -119,8 +118,6 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @PublicPage |
|
|
|
|
* |
|
|
|
|
* Resolve from a public page |
|
|
|
|
* |
|
|
|
|
* @param string $reference Reference to resolve |
|
|
|
@ -130,6 +127,7 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
* 200: Reference returned |
|
|
|
|
*/ |
|
|
|
|
#[ApiRoute(verb: 'GET', url: '/resolvePublic', root: '/references')] |
|
|
|
|
#[PublicPage] |
|
|
|
|
#[AnonRateLimit(limit: 10, period: 120)] |
|
|
|
|
public function resolveOnePublic(string $reference, string $sharingToken): DataResponse { |
|
|
|
|
/** @var ?CoreReference $resolvedReference */ |
|
|
|
@ -141,8 +139,6 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @NoAdminRequired |
|
|
|
|
* |
|
|
|
|
* Resolve multiple references |
|
|
|
|
* |
|
|
|
|
* @param string[] $references References to resolve |
|
|
|
@ -151,6 +147,7 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
* |
|
|
|
|
* 200: References returned |
|
|
|
|
*/ |
|
|
|
|
#[NoAdminRequired] |
|
|
|
|
#[ApiRoute(verb: 'POST', url: '/resolve', root: '/references')] |
|
|
|
|
public function resolve(array $references, int $limit = 1): DataResponse { |
|
|
|
|
$result = []; |
|
|
|
@ -169,8 +166,6 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @PublicPage |
|
|
|
|
* |
|
|
|
|
* Resolve multiple references from a public page |
|
|
|
|
* |
|
|
|
|
* @param string[] $references References to resolve |
|
|
|
@ -181,6 +176,7 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
* 200: References returned |
|
|
|
|
*/ |
|
|
|
|
#[ApiRoute(verb: 'POST', url: '/resolvePublic', root: '/references')] |
|
|
|
|
#[PublicPage] |
|
|
|
|
#[AnonRateLimit(limit: 10, period: 120)] |
|
|
|
|
public function resolvePublic(array $references, string $sharingToken, int $limit = 1): DataResponse { |
|
|
|
|
$result = []; |
|
|
|
@ -199,14 +195,13 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @NoAdminRequired |
|
|
|
|
* |
|
|
|
|
* Get the providers |
|
|
|
|
* |
|
|
|
|
* @return DataResponse<Http::STATUS_OK, CoreReferenceProvider[], array{}> |
|
|
|
|
* |
|
|
|
|
* 200: Providers returned |
|
|
|
|
*/ |
|
|
|
|
#[NoAdminRequired] |
|
|
|
|
#[ApiRoute(verb: 'GET', url: '/providers', root: '/references')] |
|
|
|
|
public function getProvidersInfo(): DataResponse { |
|
|
|
|
$providers = $this->referenceManager->getDiscoverableProviders(); |
|
|
|
@ -217,8 +212,6 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @NoAdminRequired |
|
|
|
|
* |
|
|
|
|
* Touch a provider |
|
|
|
|
* |
|
|
|
|
* @param string $providerId ID of the provider |
|
|
|
@ -227,6 +220,7 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { |
|
|
|
|
* |
|
|
|
|
* 200: Provider touched |
|
|
|
|
*/ |
|
|
|
|
#[NoAdminRequired] |
|
|
|
|
#[ApiRoute(verb: 'PUT', url: '/provider/{providerId}', root: '/references')] |
|
|
|
|
public function touchProvider(string $providerId, ?int $timestamp = null): DataResponse { |
|
|
|
|
if ($this->userId !== null) { |
|
|
|
|