Skip to content

Commit da7250f

Browse files
kesselbVicDeo
andcommitted
fix(sharing): do not notify remote if owner and sharee are local users
If both the owner and the sharee are local users, no remote notification is required. If either the owner or the sharee is not a local user, the change must be propagated. Based on owncloud/core#37534 Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de> Co-authored-by: Victor Dubiniuk <victor.dubiniuk@gmail.com>
1 parent 9afbad3 commit da7250f

3 files changed

Lines changed: 436 additions & 13 deletions

File tree

apps/federatedfilesharing/lib/FederatedShareProvider.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,29 @@ public function update(IShare $share): IShare {
329329
->set('expiration', $qb->createNamedParameter($share->getExpirationDate(), IQueryBuilder::PARAM_DATETIME_MUTABLE))
330330
->executeStatement();
331331

332-
// send the updated permission to the owner/initiator, if they are not the same
333-
if ($share->getShareOwner() !== $share->getSharedBy()) {
332+
/*
333+
* If the share owner and share initiator are on the same instance,
334+
* then we're done here as the share was just updated above.
335+
*
336+
* However, if the share owner/sharee is on a remote instance (and thus we're dealing with a federated share),
337+
* then we are supposed to let the share owner/ sharee on the remote instance know.
338+
*/
339+
if ($this->shouldNotifyRemote($share)) {
334340
$this->sendPermissionUpdate($share);
335341
}
336342

337343
return $share;
338344
}
339345

346+
/**
347+
* Notify owner/sharee if they are not the same and ANY of them is a remote user.
348+
*/
349+
protected function shouldNotifyRemote(IShare $share): bool {
350+
$ownerOrSharerIsRemoteUser = !$this->userManager->userExists($share->getShareOwner())
351+
|| !$this->userManager->userExists($share->getSharedBy());
352+
return $ownerOrSharerIsRemoteUser && $share->getShareOwner() !== $share->getSharedBy();
353+
}
354+
340355
/**
341356
* Send the updated permission to the owner/initiator, if they are not the same.
342357
*
@@ -466,13 +481,8 @@ public function delete(IShare $share) {
466481
* @throws HintException
467482
*/
468483
protected function revokeShare($share, $isOwner) {
469-
if ($this->userManager->userExists($share->getShareOwner()) && $this->userManager->userExists($share->getSharedBy())) {
470-
// If both the owner and the initiator of the share are local users we don't have to notify anybody else
471-
return;
472-
}
473-
474484
// also send a unShare request to the initiator, if this is a different user than the owner
475-
if ($share->getShareOwner() !== $share->getSharedBy()) {
485+
if ($this->shouldNotifyRemote($share)) {
476486
if ($isOwner) {
477487
[, $remote] = $this->addressHandler->splitUserRemote($share->getSharedBy());
478488
} else {

0 commit comments

Comments
 (0)