@@ -311,14 +311,29 @@ public function update(IShare $share) {
311311 ->set ('expiration ' , $ qb ->createNamedParameter ($ share ->getExpirationDate (), IQueryBuilder::PARAM_DATETIME_MUTABLE ))
312312 ->executeStatement ();
313313
314- // send the updated permission to the owner/initiator, if they are not the same
315- if ($ share ->getShareOwner () !== $ share ->getSharedBy ()) {
314+ /*
315+ * If the share owner and share initiator are on the same instance,
316+ * then we're done here as the share was just updated above.
317+ *
318+ * However, if the share owner/sharee is on a remote instance (and thus we're dealing with a federated share),
319+ * then we are supposed to let the share owner/ sharee on the remote instance know.
320+ */
321+ if ($ this ->shouldNotifyRemote ($ share )) {
316322 $ this ->sendPermissionUpdate ($ share );
317323 }
318324
319325 return $ share ;
320326 }
321327
328+ /**
329+ * Notify owner/sharee if they are not the same and ANY of them is a remote user.
330+ */
331+ protected function shouldNotifyRemote (IShare $ share ): bool {
332+ $ ownerOrSharerIsRemoteUser = !$ this ->userManager ->userExists ($ share ->getShareOwner ())
333+ || !$ this ->userManager ->userExists ($ share ->getSharedBy ());
334+ return $ ownerOrSharerIsRemoteUser && $ share ->getShareOwner () !== $ share ->getSharedBy ();
335+ }
336+
322337 /**
323338 * send the updated permission to the owner/initiator, if they are not the same
324339 *
@@ -457,13 +472,8 @@ public function delete(IShare $share) {
457472 * @throws HintException
458473 */
459474 protected function revokeShare ($ share , $ isOwner ) {
460- if ($ this ->userManager ->userExists ($ share ->getShareOwner ()) && $ this ->userManager ->userExists ($ share ->getSharedBy ())) {
461- // If both the owner and the initiator of the share are local users we don't have to notify anybody else
462- return ;
463- }
464-
465475 // also send a unShare request to the initiator, if this is a different user than the owner
466- if ($ share -> getShareOwner () !== $ share-> getSharedBy ( )) {
476+ if ($ this -> shouldNotifyRemote ( $ share )) {
467477 if ($ isOwner ) {
468478 [, $ remote ] = $ this ->addressHandler ->splitUserRemote ($ share ->getSharedBy ());
469479 } else {
0 commit comments