@@ -108,12 +108,12 @@ public function searchRecipients(ShareAccessContext $accessContext, ?array $reci
108108 } else {
109109 $ recipientTypes = array_values (array_filter (
110110 $ recipientTypes ,
111- static fn (IShareRecipientType $ recipientType ): bool => $ recipientType instanceof IShareRecipientTypeSearch,
111+ static fn (IShareRecipientType $ recipientType ): bool => $ recipientType instanceof IShareRecipientTypeSearch,
112112 ));
113113 }
114114
115115 return array_merge (...array_map (
116- static fn (IShareRecipientTypeSearch $ recipientType ): array => $ recipientType ->searchRecipients ($ accessContext , $ query , $ limit , $ offset ),
116+ static fn (IShareRecipientTypeSearch $ recipientType ): array => $ recipientType ->searchRecipients ($ accessContext , $ query , $ limit , $ offset ),
117117 $ recipientTypes ,
118118 ));
119119 }
@@ -201,10 +201,12 @@ public function addShareSource(ShareAccessContext $accessContext, string $id, Sh
201201 throw new ShareInvalidException ('Invalid source: ' . $ source ->value . ' ' . $ source ->class , $ this ->l10n ->t ('The source does not exist. ' ));
202202 }
203203
204- $ share = $ this ->getShare ($ accessContext , $ id , $ backend );
205- $ sources = $ share ->sources ;
206- $ sources [] = $ source ;
207- $ this ->validateInteraction ($ accessContext , $ owner , $ sources , $ share ->getEnabledPermissions (), $ share ->recipients );
204+ if (!$ accessContext ->overrideChecks ) {
205+ $ share = $ this ->getShare ($ accessContext , $ id , $ backend );
206+ $ sources = $ share ->sources ;
207+ $ sources [] = $ source ;
208+ $ this ->validateInteraction ($ accessContext , $ owner , $ sources , $ share ->getEnabledPermissions (), $ share ->recipients );
209+ }
208210
209211 $ backend ->addShareSource ($ id , $ source );
210212 }
@@ -277,10 +279,12 @@ public function addShareRecipient(ShareAccessContext $accessContext, string $id,
277279 throw new ShareInvalidException ('Invalid recipient: ' . $ recipient ->value . ' ' . $ recipient ->class . ' ' . ($ recipient ->instance ?? 'local ' ), $ this ->l10n ->t ('The recipient does not exist. ' ));
278280 }
279281
280- $ share ??= $ this ->getShare ($ accessContext , $ id , $ backend );
281- $ recipients = $ share ->recipients ;
282- $ recipients [] = $ recipient ;
283- $ this ->validateInteraction ($ accessContext , $ owner , $ share ->sources , $ share ->getEnabledPermissions (), $ recipients );
282+ if (!$ accessContext ->overrideChecks ) {
283+ $ share ??= $ this ->getShare ($ accessContext , $ id , $ backend );
284+ $ recipients = $ share ->recipients ;
285+ $ recipients [] = $ recipient ;
286+ $ this ->validateInteraction ($ accessContext , $ owner , $ share ->sources , $ share ->getEnabledPermissions (), $ recipients );
287+ }
284288
285289 $ backend ->addShareRecipient ($ id , $ currentUser , $ recipient );
286290 }
@@ -423,12 +427,12 @@ public function updateSharePermission(ShareAccessContext $accessContext, string
423427 throw new RuntimeException ('The permission type is not registered: ' . $ permission ->class );
424428 }
425429
426- $ share = $ this -> getShare ( $ accessContext, $ id , $ backend );
427-
428- $ permissions = $ share ->permissions ;
429- $ permissions [$ permission ->class ] = $ permission ;
430-
431- $ this -> validateInteraction ( $ accessContext , $ owner , $ share -> sources , array_filter ( $ permissions , static fn ( SharePermission $ permission ): bool => $ permission -> enabled ), $ share -> recipients );
430+ if (! $ accessContext-> overrideChecks ) {
431+ $ share = $ this -> getShare ( $ accessContext , $ id , $ backend );
432+ $ permissions = $ share ->permissions ;
433+ $ permissions [$ permission ->class ] = $ permission ;
434+ $ this -> validateInteraction ( $ accessContext , $ owner , $ share -> sources , array_filter ( $ permissions , static fn ( SharePermission $ permission ): bool => $ permission -> enabled ), $ share -> recipients );
435+ }
432436
433437 $ backend ->updateSharePermission ($ id , $ permission );
434438
@@ -547,6 +551,7 @@ private function getBackend(?string $id): ISharingBackend {
547551 }
548552
549553 // TODO: Support IShareOwnerlessMount
554+
550555 /**
551556 * @throws ShareOperationForbiddenException
552557 */
@@ -600,7 +605,7 @@ private function validateReshareOperation(ShareAccessContext $accessContext, Sha
600605 * @throws ShareInvalidException
601606 */
602607 private function validateInteraction (ShareAccessContext $ accessContext , ShareUser $ owner , array $ sources , array $ enabledPermissions , array $ recipients ): void {
603- $ action = new ShareAction (null , array_values (array_map (static fn (SharePermission $ permission ): string => $ permission ->class , $ enabledPermissions )));
608+ $ action = new ShareAction (null , array_values (array_map (static fn (SharePermission $ permission ): string => $ permission ->class , $ enabledPermissions )));
604609
605610 $ usersToCheck = [];
606611 if ($ owner ->instance === null && ($ ownerUser = $ this ->userManager ->get ($ owner ->userId )) !== null ) {
0 commit comments