Skip to content

Commit 194bd5b

Browse files
authored
Merge pull request #58719 from nextcloud/backport/57667/stable33
2 parents 1aceee6 + e36159f commit 194bd5b

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
@@ -301,14 +301,29 @@ public function update(IShare $share): IShare {
301301
->set('expiration', $qb->createNamedParameter($share->getExpirationDate(), IQueryBuilder::PARAM_DATETIME_MUTABLE))
302302
->executeStatement();
303303

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

309315
return $share;
310316
}
311317

318+
/**
319+
* Notify owner/sharee if they are not the same and ANY of them is a remote user.
320+
*/
321+
protected function shouldNotifyRemote(IShare $share): bool {
322+
$ownerOrSharerIsRemoteUser = !$this->userManager->userExists($share->getShareOwner())
323+
|| !$this->userManager->userExists($share->getSharedBy());
324+
return $ownerOrSharerIsRemoteUser && $share->getShareOwner() !== $share->getSharedBy();
325+
}
326+
312327
/**
313328
* Send the updated permission to the owner/initiator, if they are not the same.
314329
*
@@ -438,13 +453,8 @@ public function delete(IShare $share) {
438453
* @throws HintException
439454
*/
440455
protected function revokeShare($share, $isOwner) {
441-
if ($this->userManager->userExists($share->getShareOwner()) && $this->userManager->userExists($share->getSharedBy())) {
442-
// If both the owner and the initiator of the share are local users we don't have to notify anybody else
443-
return;
444-
}
445-
446456
// also send a unShare request to the initiator, if this is a different user than the owner
447-
if ($share->getShareOwner() !== $share->getSharedBy()) {
457+
if ($this->shouldNotifyRemote($share)) {
448458
if ($isOwner) {
449459
[, $remote] = $this->addressHandler->splitUserRemote($share->getSharedBy());
450460
} else {

0 commit comments

Comments
 (0)