Skip to content
Open
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: 18 additions & 8 deletions apps/federatedfilesharing/lib/FederatedShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,29 @@ public function update(IShare $share): IShare {
->set('expiration', $qb->createNamedParameter($share->getExpirationDate(), IQueryBuilder::PARAM_DATETIME_MUTABLE))
->executeStatement();

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

return $share;
}

/**
* Notify owner/sharee if they are not the same and ANY of them is a remote user.
*/
protected function shouldNotifyRemote(IShare $share): bool {
$ownerOrSharerIsRemoteUser = !$this->userManager->userExists($share->getShareOwner())
|| !$this->userManager->userExists($share->getSharedBy());
return $ownerOrSharerIsRemoteUser && $share->getShareOwner() !== $share->getSharedBy();
}

/**
* Send the updated permission to the owner/initiator, if they are not the same.
*
Expand Down Expand Up @@ -466,13 +481,8 @@ public function delete(IShare $share) {
* @throws HintException
*/
protected function revokeShare($share, $isOwner) {
if ($this->userManager->userExists($share->getShareOwner()) && $this->userManager->userExists($share->getSharedBy())) {
// If both the owner and the initiator of the share are local users we don't have to notify anybody else
return;
}

// 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) {
[, $remote] = $this->addressHandler->splitUserRemote($share->getSharedBy());
} else {
Expand Down
Loading
Loading