Skip to content

Commit 3d8d3b7

Browse files
committed
small fixes
Signed-off-by: Maxence Lange <[email protected]>
1 parent a4303c6 commit 3d8d3b7

File tree

5 files changed

+126
-12
lines changed

5 files changed

+126
-12
lines changed

apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@
3333
use OCP\OCM\Exceptions\OCMProviderException;
3434
use OCP\OCM\IOCMDiscoveryService;
3535
use OCP\OCS\IDiscoveryService;
36+
use Psr\Log\LoggerInterface;
3637

3738
class FederatedSharesDiscoverJob extends TimedJob {
3839

3940
public function __construct(
4041
ITimeFactory $time,
4142
private IDBConnection $connection,
4243
private IDiscoveryService $discoveryService,
43-
private IOCMDiscoveryService $ocmDiscoveryService
44+
private IOCMDiscoveryService $ocmDiscoveryService,
45+
private LoggerInterface $logger,
4446
) {
4547
parent::__construct($time);
4648
$this->setInterval(86400);
@@ -58,6 +60,7 @@ public function run($argument) {
5860
try {
5961
$this->ocmDiscoveryService->discover($row['remote'], true);
6062
} catch (OCMProviderException $e) {
63+
$this->logger->info('exception while running files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob', ['exception' => $e]);
6164
}
6265
}
6366
$result->closeCursor();

build/psalm-baseline.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@
4343
<code>IEventListener</code>
4444
</MissingTemplateParam>
4545
</file>
46-
<file src="apps/cloud_federation_api/lib/Capabilities.php">
47-
<LessSpecificImplementedReturnType>
48-
<code>array</code>
49-
</LessSpecificImplementedReturnType>
50-
</file>
5146
<file src="apps/comments/lib/Listener/CommentsEntityEventListener.php">
5247
<MissingTemplateParam>
5348
<code>IEventListener</code>

core/Controller/OCMController.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@
2929
use Exception;
3030
use OCP\AppFramework\Controller;
3131
use OCP\AppFramework\Http;
32-
use OCP\AppFramework\Http\Attribute\IgnoreOpenAPI;
3332
use OCP\AppFramework\Http\DataResponse;
34-
use OCP\AppFramework\Http\Response;
33+
use OCP\Capabilities\ICapability;
3534
use OCP\IConfig;
3635
use OCP\IRequest;
3736
use OCP\Server;
@@ -58,11 +57,14 @@ public function __construct(
5857
*
5958
* @PublicPage
6059
* @NoCSRFRequired
60+
* @psalm-suppress MoreSpecificReturnType
61+
* @psalm-suppress LessSpecificReturnStatement
62+
* @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{}>
6163
*
62-
* @return Response
64+
* 200: OCM Provider details returned
65+
* 500: OCM not supported
6366
*/
64-
#[IgnoreOpenAPI]
65-
public function discovery(): Response {
67+
public function discovery(): DataResponse {
6668
try {
6769
$cap = Server::get(
6870
$this->config->getAppValue(
@@ -72,6 +74,10 @@ public function discovery(): Response {
7274
)
7375
);
7476

77+
if (!($cap instanceof ICapability)) {
78+
throw new Exception('loaded class does not implements OCP\Capabilities\ICapability');
79+
}
80+
7581
return new DataResponse(
7682
$cap->getCapabilities()['ocm'] ?? ['enabled' => false],
7783
Http::STATUS_OK,

core/openapi.json

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,116 @@
12891289
}
12901290
}
12911291
},
1292+
"/index.php/ocm-provider": {
1293+
"get": {
1294+
"operationId": "ocm-discovery",
1295+
"summary": "generate a OCMProvider with local data and send it as DataResponse. This replaces the old PHP file ocm-provider/index.php",
1296+
"tags": [
1297+
"ocm"
1298+
],
1299+
"security": [
1300+
{},
1301+
{
1302+
"bearer_auth": []
1303+
},
1304+
{
1305+
"basic_auth": []
1306+
}
1307+
],
1308+
"responses": {
1309+
"200": {
1310+
"description": "OCM Provider details returned",
1311+
"headers": {
1312+
"X-NEXTCLOUD-OCM-PROVIDERS": {
1313+
"schema": {
1314+
"type": "boolean"
1315+
}
1316+
}
1317+
},
1318+
"content": {
1319+
"application/json": {
1320+
"schema": {
1321+
"type": "object",
1322+
"required": [
1323+
"enabled",
1324+
"apiVersion",
1325+
"endPoint",
1326+
"resourceTypes"
1327+
],
1328+
"properties": {
1329+
"enabled": {
1330+
"type": "boolean"
1331+
},
1332+
"apiVersion": {
1333+
"type": "string"
1334+
},
1335+
"endPoint": {
1336+
"type": "string"
1337+
},
1338+
"resourceTypes": {
1339+
"type": "object",
1340+
"required": [
1341+
null
1342+
],
1343+
"properties": {
1344+
"": {
1345+
"type": "object",
1346+
"required": [
1347+
"name",
1348+
"shareTypes",
1349+
"protocols"
1350+
],
1351+
"properties": {
1352+
"name": {
1353+
"type": "string"
1354+
},
1355+
"shareTypes": {
1356+
"type": "array",
1357+
"items": {
1358+
"type": "string"
1359+
}
1360+
},
1361+
"protocols": {
1362+
"type": "object",
1363+
"required": [
1364+
"webdav"
1365+
],
1366+
"properties": {
1367+
"webdav": {
1368+
"type": "string"
1369+
}
1370+
}
1371+
}
1372+
}
1373+
}
1374+
}
1375+
}
1376+
}
1377+
}
1378+
}
1379+
}
1380+
},
1381+
"500": {
1382+
"description": "OCM not supported",
1383+
"content": {
1384+
"application/json": {
1385+
"schema": {
1386+
"type": "object",
1387+
"required": [
1388+
"message"
1389+
],
1390+
"properties": {
1391+
"message": {
1392+
"type": "string"
1393+
}
1394+
}
1395+
}
1396+
}
1397+
}
1398+
}
1399+
}
1400+
}
1401+
},
12921402
"/ocs/v2.php/cloud/capabilities": {
12931403
"get": {
12941404
"operationId": "ocs-get-capabilities",

lib/private/OCM/Model/OCMProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private function looksValid(): bool {
196196
* }
197197
*/
198198
public function jsonSerialize(): array {
199-
$resourceTypes = []; // this is needed for psalm
199+
$resourceTypes = [];
200200
foreach ($this->getResourceTypes() as $res) {
201201
$resourceTypes[] = $res->jsonSerialize();
202202
}

0 commit comments

Comments
 (0)