Skip to content

Commit 2dc5111

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 0c98c47 commit 2dc5111

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

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

319325
return $share;
320326
}
321327

328+
/**
329+
* Notify owner/sharee if they are not the same and ANY of them is a remote user.
330+
*/
331+
protected function shouldNotifyRemote(IShare $share): bool {
332+
$ownerOrSharerIsRemoteUser = !$this->userManager->userExists($share->getShareOwner())
333+
|| !$this->userManager->userExists($share->getSharedBy());
334+
return $ownerOrSharerIsRemoteUser && $share->getShareOwner() !== $share->getSharedBy();
335+
}
336+
322337
/**
323338
* send the updated permission to the owner/initiator, if they are not the same
324339
*
@@ -457,13 +472,8 @@ public function delete(IShare $share) {
457472
* @throws HintException
458473
*/
459474
protected function revokeShare($share, $isOwner) {
460-
if ($this->userManager->userExists($share->getShareOwner()) && $this->userManager->userExists($share->getSharedBy())) {
461-
// If both the owner and the initiator of the share are local users we don't have to notify anybody else
462-
return;
463-
}
464-
465475
// also send a unShare request to the initiator, if this is a different user than the owner
466-
if ($share->getShareOwner() !== $share->getSharedBy()) {
476+
if ($this->shouldNotifyRemote($share)) {
467477
if ($isOwner) {
468478
[, $remote] = $this->addressHandler->splitUserRemote($share->getSharedBy());
469479
} else {

0 commit comments

Comments
 (0)