mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 01:30:50 -04:00
fix(shares): Promote reshares into direct shares when share is deleted
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
f0e10eaeed
commit
c7dbe7e71c
1 changed files with 13 additions and 6 deletions
|
|
@ -1032,7 +1032,8 @@ class Manager implements IManager {
|
|||
return $deletedShares;
|
||||
}
|
||||
|
||||
protected function deleteReshares(IShare $share): void {
|
||||
/* Promote reshares into direct shares so that target user keeps access */
|
||||
protected function promoteReshares(IShare $share): void {
|
||||
try {
|
||||
$node = $share->getNode();
|
||||
} catch (NotFoundException) {
|
||||
|
|
@ -1050,7 +1051,7 @@ class Manager implements IManager {
|
|||
|
||||
foreach ($users as $user) {
|
||||
/* Skip share owner */
|
||||
if ($user->getUID() === $share->getShareOwner()) {
|
||||
if ($user->getUID() === $share->getShareOwner() || $user->getUID() === $share->getSharedBy()) {
|
||||
continue;
|
||||
}
|
||||
$userIds[] = $user->getUID();
|
||||
|
|
@ -1093,8 +1094,14 @@ class Manager implements IManager {
|
|||
try {
|
||||
$this->generalCreateChecks($child);
|
||||
} catch (GenericShareException $e) {
|
||||
$this->logger->debug('Delete reshare because of exception '.$e->getMessage(), ['exception' => $e]);
|
||||
$this->deleteShare($child);
|
||||
/* The check is invalid, promote it to a direct share from the sharer of parent share */
|
||||
$this->logger->debug('Promote reshare because of exception ' . $e->getMessage(), ['exception' => $e, 'fullId' => $child->getFullId()]);
|
||||
try {
|
||||
$child->setSharedBy($share->getSharedBy());
|
||||
$this->updateShare($child);
|
||||
} catch (GenericShareException|\InvalidArgumentException $e) {
|
||||
$this->logger->warning('Failed to promote reshare because of exception ' . $e->getMessage(), ['exception' => $e, 'fullId' => $child->getFullId()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1124,8 +1131,8 @@ class Manager implements IManager {
|
|||
|
||||
$this->dispatcher->dispatchTyped(new ShareDeletedEvent($share));
|
||||
|
||||
// Delete reshares of the deleted share
|
||||
$this->deleteReshares($share);
|
||||
// Promote reshares of the deleted share
|
||||
$this->promoteReshares($share);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue