Skip to content

Commit e3ed9e4

Browse files
kesselbVicDeo
andcommitted
fix(sharing): do not notify remote if owner and sharee are local users
If both the owner and the sharee are local users, no remote notification is required. If either the owner or the sharee is not a local user, the change must be propagated. Based on owncloud/core#37534 Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de> Co-authored-by: Victor Dubiniuk <victor.dubiniuk@gmail.com>
1 parent a887e0f commit e3ed9e4

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

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

347353
return $share;
348354
}
349355

356+
/**
357+
* Notify owner/sharee if they are not the same and ANY of them is a remote user.
358+
*/
359+
protected function shouldNotifyRemote(IShare $share): bool {
360+
$ownerOrSharerIsRemoteUser = !$this->userManager->userExists($share->getShareOwner())
361+
|| !$this->userManager->userExists($share->getSharedBy());
362+
return $ownerOrSharerIsRemoteUser && $share->getShareOwner() !== $share->getSharedBy();
363+
}
364+
350365
/**
351366
* send the updated permission to the owner/initiator, if they are not the same
352367
*
@@ -485,13 +500,8 @@ public function delete(IShare $share) {
485500
* @throws HintException
486501
*/
487502
protected function revokeShare($share, $isOwner) {
488-
if ($this->userManager->userExists($share->getShareOwner()) && $this->userManager->userExists($share->getSharedBy())) {
489-
// If both the owner and the initiator of the share are local users we don't have to notify anybody else
490-
return;
491-
}
492-
493503
// also send a unShare request to the initiator, if this is a different user than the owner
494-
if ($share->getShareOwner() !== $share->getSharedBy()) {
504+
if ($this->shouldNotifyRemote($share)) {
495505
if ($isOwner) {
496506
[, $remote] = $this->addressHandler->splitUserRemote($share->getSharedBy());
497507
} else {

0 commit comments

Comments
 (0)