Skip to content

Commit

Permalink
Make sure that either owner or initiator of federated share is not lo…
Browse files Browse the repository at this point in the history
…cal user
  • Loading branch information
VicDeo committed Jun 16, 2020
1 parent 2aca8a4 commit 3fd3ac3
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 146 deletions.
22 changes: 18 additions & 4 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 @@ -517,7 +531,7 @@ public function delete(IShare $share) {
}

// send revoke notification to the other user, if initiator and owner are not the same user
if ($share->getShareOwner() !== $share->getSharedBy()) {
if ($this->shouldNotifyRemote($share)) {
$remoteId = $this->getRemoteId($share);
if ($isOwner) {
list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy());
Expand All @@ -540,7 +554,7 @@ public function delete(IShare $share) {
*/
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()) {
if ($this->shouldNotifyRemote($share)) {
if ($isOwner) {
list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy());
} else {
Expand Down
Loading

0 comments on commit 3fd3ac3

Please sign in to comment.