Skip to content

Commit

Permalink
Merge pull request #37534 from owncloud/bugfix/e3983
Browse files Browse the repository at this point in the history
Make sure that either owner or initiator of federated share is not lo…
  • Loading branch information
VicDeo authored Jun 17, 2020
2 parents 72b83e2 + 1972cd0 commit 66b8373
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 148 deletions.
26 changes: 20 additions & 6 deletions apps/federatedfilesharing/lib/FederatedShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,28 @@ public function update(IShare $share) {
->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()))
->execute();

// send the updated permission to the owner/initiator, if they are not the same
if ($share->getShareOwner() !== $share->getSharedBy()) {
// send the updated permission to the owner/initiator
if ($this->shouldNotifyRemote($share)) {
$this->sendPermissionUpdate($share);
}

return $share;
}

/**
* User based check
*
* @param IShare $share
* @return bool
*/
protected function shouldNotifyRemote($share) {
// We notify owner/initiator, if they are not the same user and ANY of them is NOT a local user
// they could be both local e.g. if recipient of local share shared it via federation
$isRemoteUserInvolved = $this->userManager->userExists($share->getShareOwner()) == false
|| $this->userManager->userExists($share->getSharedBy()) == false;
return $isRemoteUserInvolved && $share->getShareOwner() !== $share->getSharedBy();
}

/**
* send the updated permission to the owner/initiator, if they are not the same
*
Expand Down Expand Up @@ -516,8 +530,8 @@ public function delete(IShare $share) {
$this->revokeShare($share, false);
}

// send revoke notification to the other user, if initiator and owner are not the same user
if ($share->getShareOwner() !== $share->getSharedBy()) {
// send revoke notification to the other user
if ($this->shouldNotifyRemote($share)) {
$remoteId = $this->getRemoteId($share);
if ($isOwner) {
list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy());
Expand All @@ -539,8 +553,8 @@ public function delete(IShare $share) {
* @throws \OC\HintException
*/
protected function revokeShare($share, $isOwner) {
// also send a unShare request to the initiator, if this is a different user than the owner
if ($share->getShareOwner() !== $share->getSharedBy()) {
// also send a unShare request to the initiator
if ($this->shouldNotifyRemote($share)) {
if ($isOwner) {
list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy());
} else {
Expand Down
Loading

0 comments on commit 66b8373

Please sign in to comment.