mirror of
https://github.com/nextcloud/server.git
synced 2026-03-21 10:00:33 -04:00
small fixes
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
This commit is contained in:
parent
c6c06d517c
commit
b5dcd048ae
5 changed files with 126 additions and 12 deletions
|
|
@ -33,6 +33,7 @@ use OCP\IDBConnection;
|
|||
use OCP\OCM\Exceptions\OCMProviderException;
|
||||
use OCP\OCM\IOCMDiscoveryService;
|
||||
use OCP\OCS\IDiscoveryService;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class FederatedSharesDiscoverJob extends TimedJob {
|
||||
|
||||
|
|
@ -40,7 +41,8 @@ class FederatedSharesDiscoverJob extends TimedJob {
|
|||
ITimeFactory $time,
|
||||
private IDBConnection $connection,
|
||||
private IDiscoveryService $discoveryService,
|
||||
private IOCMDiscoveryService $ocmDiscoveryService
|
||||
private IOCMDiscoveryService $ocmDiscoveryService,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
parent::__construct($time);
|
||||
$this->setInterval(86400);
|
||||
|
|
@ -58,6 +60,7 @@ class FederatedSharesDiscoverJob extends TimedJob {
|
|||
try {
|
||||
$this->ocmDiscoveryService->discover($row['remote'], true);
|
||||
} catch (OCMProviderException $e) {
|
||||
$this->logger->info('exception while running files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob', ['exception' => $e]);
|
||||
}
|
||||
}
|
||||
$result->closeCursor();
|
||||
|
|
|
|||
|
|
@ -43,11 +43,6 @@
|
|||
<code>IEventListener</code>
|
||||
</MissingTemplateParam>
|
||||
</file>
|
||||
<file src="apps/cloud_federation_api/lib/Capabilities.php">
|
||||
<LessSpecificImplementedReturnType>
|
||||
<code>array</code>
|
||||
</LessSpecificImplementedReturnType>
|
||||
</file>
|
||||
<file src="apps/comments/lib/Listener/CommentsEntityEventListener.php">
|
||||
<MissingTemplateParam>
|
||||
<code>IEventListener</code>
|
||||
|
|
|
|||
|
|
@ -29,9 +29,8 @@ namespace OC\Core\Controller;
|
|||
use Exception;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\Attribute\IgnoreOpenAPI;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\Capabilities\ICapability;
|
||||
use OCP\IConfig;
|
||||
use OCP\IRequest;
|
||||
use OCP\Server;
|
||||
|
|
@ -58,11 +57,14 @@ class OCMController extends Controller {
|
|||
*
|
||||
* @PublicPage
|
||||
* @NoCSRFRequired
|
||||
* @psalm-suppress MoreSpecificReturnType
|
||||
* @psalm-suppress LessSpecificReturnStatement
|
||||
* @return DataResponse<Http::STATUS_OK, array{enabled: bool, apiVersion: string, endPoint: string, resourceTypes: array{array{name: string, shareTypes: string[], protocols: array{webdav: string}}}}, array{X-NEXTCLOUD-OCM-PROVIDERS: true, Content-Type: 'application/json'}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
|
||||
*
|
||||
* @return Response
|
||||
* 200: OCM Provider details returned
|
||||
* 500: OCM not supported
|
||||
*/
|
||||
#[IgnoreOpenAPI]
|
||||
public function discovery(): Response {
|
||||
public function discovery(): DataResponse {
|
||||
try {
|
||||
$cap = Server::get(
|
||||
$this->config->getAppValue(
|
||||
|
|
@ -72,6 +74,10 @@ class OCMController extends Controller {
|
|||
)
|
||||
);
|
||||
|
||||
if (!($cap instanceof ICapability)) {
|
||||
throw new Exception('loaded class does not implements OCP\Capabilities\ICapability');
|
||||
}
|
||||
|
||||
return new DataResponse(
|
||||
$cap->getCapabilities()['ocm'] ?? ['enabled' => false],
|
||||
Http::STATUS_OK,
|
||||
|
|
|
|||
|
|
@ -1289,6 +1289,116 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/index.php/ocm-provider": {
|
||||
"get": {
|
||||
"operationId": "ocm-discovery",
|
||||
"summary": "generate a OCMProvider with local data and send it as DataResponse. This replaces the old PHP file ocm-provider/index.php",
|
||||
"tags": [
|
||||
"ocm"
|
||||
],
|
||||
"security": [
|
||||
{},
|
||||
{
|
||||
"bearer_auth": []
|
||||
},
|
||||
{
|
||||
"basic_auth": []
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OCM Provider details returned",
|
||||
"headers": {
|
||||
"X-NEXTCLOUD-OCM-PROVIDERS": {
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"enabled",
|
||||
"apiVersion",
|
||||
"endPoint",
|
||||
"resourceTypes"
|
||||
],
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"apiVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"endPoint": {
|
||||
"type": "string"
|
||||
},
|
||||
"resourceTypes": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
null
|
||||
],
|
||||
"properties": {
|
||||
"": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"shareTypes",
|
||||
"protocols"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"shareTypes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"protocols": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"webdav"
|
||||
],
|
||||
"properties": {
|
||||
"webdav": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "OCM not supported",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"message"
|
||||
],
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/ocs/v2.php/cloud/capabilities": {
|
||||
"get": {
|
||||
"operationId": "ocs-get-capabilities",
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ class OCMProvider implements IOCMProvider, JsonSerializable {
|
|||
* }
|
||||
*/
|
||||
public function jsonSerialize(): array {
|
||||
$resourceTypes = []; // this is needed for psalm
|
||||
$resourceTypes = [];
|
||||
foreach ($this->getResourceTypes() as $res) {
|
||||
$resourceTypes[] = $res->jsonSerialize();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue