Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion apps/sharing/lib/Controller/ApiV1Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public function getShare(string $id, ?string $secret = null, array $arguments =
* Get multiple shares.
*
* @param ?class-string<IShareSourceType> $filterSourceTypeClass Source type class to filter by.
* @param ?string $filterSourceTypeValue Source type value to filter by.
* @param ?non-empty-string $filterSourceTypeValue Source type value to filter by.
* @param ?string $lastShareID The ID of the previous share. This is used as an offset and only shares with higher IDs are returned.
* @param int<1, 100> $limit The number of shares to return.
* @return DataResponse<Http::STATUS_OK, list<SharingShare>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, string, array{}>
Expand All @@ -578,6 +578,15 @@ public function getShares(?string $filterSourceTypeClass, ?string $filterSourceT
return new DataResponse('The limit is too high.', Http::STATUS_BAD_REQUEST);
}

/** @psalm-suppress TypeDoesNotContainType */
if ($filterSourceTypeValue === '') {
return new DataResponse('Filter source value is empty.', Http::STATUS_BAD_REQUEST);
}

if ($filterSourceTypeClass && !isset($this->registry->getSourceTypes()[$filterSourceTypeClass])) {
return new DataResponse('The filter source type is not registered: ' . $filterSourceTypeClass, Http::STATUS_BAD_REQUEST);
}

try {
$this->dbConnection->beginTransaction();

Expand Down
3 changes: 2 additions & 1 deletion apps/sharing/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3110,7 +3110,8 @@
"description": "Source type value to filter by.",
"schema": {
"type": "string",
"nullable": true
"nullable": true,
"minLength": 1
}
},
{
Expand Down
5 changes: 2 additions & 3 deletions apps/sharing/tests/Controller/ApiV1ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
declare(strict_types=1);

use NCU\Sharing\ISharingManager;
use NCU\Sharing\ISharingRegistry;
use NCU\Sharing\Permission\SharePermission;
use NCU\Sharing\Property\ShareProperty;
use NCU\Sharing\Recipient\ShareRecipient;
Expand Down Expand Up @@ -47,7 +46,7 @@ public function testDefaultShareAccessContext(): void {
Server::get(IRequest::class),
Server::get(IUserSession::class),
Server::get(ISharingManager::class),
Server::get(ISharingRegistry::class),
$this->registry,
Server::get(IFactory::class),
Server::get(IURLGenerator::class),
Server::get(IUserManager::class),
Expand All @@ -68,7 +67,7 @@ private function executeRequest(ShareAccessContext $accessContext, Closure $clos
Server::get(IRequest::class),
Server::get(IUserSession::class),
Server::get(ISharingManager::class),
Server::get(ISharingRegistry::class),
$this->registry,
Server::get(IFactory::class),
Server::get(IURLGenerator::class),
Server::get(IUserManager::class),
Expand Down
1 change: 1 addition & 0 deletions lib/private/Sharing/SharingBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ private function hideDisabledUserShares(): bool {

/**
* @param ?class-string<IShareSourceType> $filterSourceTypeClass
* @param ?non-empty-string $filterSourceTypeValue
* @return list<Share>
*/
private function list(ShareAccessContext $accessContext, ?string $filterShareID, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Sharing/SharingManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ private function validateInteraction(ShareAccessContext $accessContext, Share $s
$action = new ShareAction(null, array_values(array_map(static fn (SharePermission $permission): string => $permission->class, $share->getEnabledPermissions())));

$usersToCheck = [];
if ($share->owner->instance === null && ($ownerUser = $this->userManager->get($share->owner->userId)) !== null) {
if ($share->owner->instance === null && ($ownerUser = $this->userManager->get($share->owner->userId)) instanceof IUser) {
$usersToCheck[] = $ownerUser;
}

Expand Down
1 change: 1 addition & 0 deletions lib/unstable/Sharing/ISharingBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public function getShare(ShareAccessContext $accessContext, string $id): Share;
* Get multiple shares.
*
* @param ?class-string<IShareSourceType> $filterSourceTypeClass
* @param ?non-empty-string $filterSourceTypeValue
* @param ?positive-int $limit
* @return list<Share>
* @experimental 35.0.0
Expand Down
1 change: 1 addition & 0 deletions lib/unstable/Sharing/ISharingManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ public function getShare(ShareAccessContext $accessContext, string $id): Share;
* Get multiple shares.
*
* @param ?class-string<IShareSourceType> $filterSourceTypeClass
* @param ?non-empty-string $filterSourceTypeValue
* @param ?positive-int $limit
* @return list<Share>
* @experimental 35.0.0
Expand Down
3 changes: 2 additions & 1 deletion openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -39006,7 +39006,8 @@
"description": "Source type value to filter by.",
"schema": {
"type": "string",
"nullable": true
"nullable": true,
"minLength": 1
}
},
{
Expand Down
Loading