Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that either owner or initiator of federated share is not lo… #37534

Merged
merged 2 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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