Skip to content

Commit 2bbf018

Browse files
committed
refactor: use IUser for IShareSourceType::getSourceInteractionResource instead of user id string
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent f2a0bb5 commit 2bbf018

5 files changed

Lines changed: 10 additions & 6 deletions

File tree

apps/files/lib/Sharing/Source/NodeShareSourceType.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use OCP\Interaction\InteractionResource;
2828
use OCP\Interaction\Resources\NodeResource;
2929
use OCP\IURLGenerator;
30+
use OCP\IUser;
3031
use OCP\L10N\IFactory;
3132

3233
/**
@@ -72,8 +73,8 @@ public function getSourceIcon(string $source): ShareIconURL {
7273
}
7374

7475
#[\Override]
75-
public function getSourceInteractionResource(string $userId, string $source): InteractionResource {
76-
return new NodeResource((int)$source, $userId);
76+
public function getSourceInteractionResource(IUser $user, string $source): InteractionResource {
77+
return new NodeResource((int)$source, $user->getUID());
7778
}
7879

7980
#[\Override]

lib/private/Sharing/SharingManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ private function validateInteraction(ShareAccessContext $accessContext, Share $s
733733
continue;
734734
}
735735

736-
$resources[] = $sourceType->getSourceInteractionResource($userToCheck->getUID(), $source->value);
736+
$resources[] = $sourceType->getSourceInteractionResource($userToCheck, $source->value);
737737
}
738738

739739
$event = new RestrictInteractionEvent($userToCheck->getUID(), $userToCheck, $resources, $action, $receivers);

lib/unstable/Sharing/Source/IShareSourceType.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use NCU\Sharing\Icon\ShareIconURL;
1414
use OCP\AppFramework\Attribute\Implementable;
1515
use OCP\Interaction\InteractionResource;
16+
use OCP\IUser;
1617
use OCP\L10N\IFactory;
1718

1819
/**
@@ -52,9 +53,9 @@ public function getSourceDisplayName(string $source): ?string;
5253
public function getSourceIcon(string $source): null|ShareIconSVG|ShareIconURL;
5354

5455
/**
55-
* @param non-empty-string $userId
56+
* @param IUser $user
5657
* @param non-empty-string $source
5758
* @experimental 35.0.0
5859
*/
59-
public function getSourceInteractionResource(string $userId, string $source): InteractionResource;
60+
public function getSourceInteractionResource(IUser $user, string $source): InteractionResource;
6061
}

tests/lib/Sharing/TestInteractionResource.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Test\Sharing;
1111

1212
use OCP\Interaction\InteractionResource;
13+
use OCP\IUser;
1314

1415
final readonly class TestInteractionResource implements InteractionResource {
1516
public function __construct(

tests/lib/Sharing/TestShareSourceType1.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use NCU\Sharing\Icon\ShareIconURL;
1414
use NCU\Sharing\Source\IShareSourceType;
1515
use OCP\Interaction\InteractionResource;
16+
use OCP\IUser;
1617
use OCP\L10N\IFactory;
1718

1819
class TestShareSourceType1 implements IShareSourceType {
@@ -45,7 +46,7 @@ public function getSourceIcon(string $source): null|ShareIconSVG|ShareIconURL {
4546
}
4647

4748
#[\Override]
48-
public function getSourceInteractionResource(string $userId, string $source): InteractionResource {
49+
public function getSourceInteractionResource(IUser $user, string $source): InteractionResource {
4950
return new TestInteractionResource($source);
5051
}
5152
}

0 commit comments

Comments
 (0)