Skip to content
Open
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
110 changes: 56 additions & 54 deletions lib/FilesHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -807,14 +807,15 @@ protected function shareWithTeam(string $shareWith, Node $fileSource, string $fi
* @throws \OCP\Files\NotFoundException
*/
public function unShare(IShare $share) {
if (in_array($share->getNodeType(), ['file', 'folder'], true) && !$this->isDeletedNode($share->getShareOwner(), $share->getNodeId())) {
if ($share->getShareType() === IShare::TYPE_USER) {
$this->unshareFromUser($share);
} elseif ($share->getShareType() === IShare::TYPE_GROUP) {
$this->unshareFromGroup($share);
} elseif ($share->getShareType() === IShare::TYPE_LINK) {
$this->unshareLink($share);
}
if (!in_array($share->getNodeType(), ['file', 'folder'], true) || $this->isDeletedNode($share->getShareOwner(), $share->getNodeId())) {
return;
}
if ($share->getShareType() === IShare::TYPE_USER) {
$this->unshareFromUser($share);
} elseif ($share->getShareType() === IShare::TYPE_GROUP) {
$this->unshareFromGroup($share);
} elseif ($share->getShareType() === IShare::TYPE_LINK) {
$this->unshareLink($share);
}
}

Expand All @@ -825,12 +826,13 @@ public function unShare(IShare $share) {
* @throws \OCP\Files\NotFoundException
*/
public function unShareSelf(IShare $share) {
if (in_array($share->getNodeType(), ['file', 'folder'], true)) {
if ($share->getShareType() === IShare::TYPE_GROUP) {
$this->unshareFromSelfGroup($share);
} elseif ($share->getShareType() === IShare::TYPE_USER) {
$this->unshareFromUser($share);
}
if (!in_array($share->getNodeType(), ['file', 'folder'], true)) {
return;
}
if ($share->getShareType() === IShare::TYPE_GROUP) {
$this->unshareFromSelfGroup($share);
} elseif ($share->getShareType() === IShare::TYPE_USER) {
$this->unshareFromUser($share);
}
}

Expand Down Expand Up @@ -1097,51 +1099,51 @@ protected function reshareNotificationForSharer(string $owner, string $subject,
*/
protected function shareNotificationForOriginalOwners(string $sharedBy, string $subject, string $shareWith, Node $fileSource) {
$mount = $fileSource->getMountPoint();
if ($mount instanceof SharedMount) {
$sourceShare = $mount->getShare();
if (!$mount instanceof SharedMount) {
return;
}

$fileId = $fileSource->getId();
$sourceShare = $mount->getShare();
$fileId = $fileSource->getId();

if ($sourceShare->getShareOwner() !== $sharedBy) {
$owner = $sourceShare->getShareOwner();
try {
$ownerNode = $this->rootFolder->getUserFolder($owner)->getFirstNodeById($fileId);
} catch (NotFoundException) {
return;
}
if ($ownerNode === null) {
return;
}
$this->reshareNotificationForSharer(
$owner,
$subject,
$shareWith,
$fileId,
$this->getUserRelativePath($owner, $ownerNode->getPath()),
$fileSource instanceof File,
);
if ($sourceShare->getShareOwner() !== $sharedBy) {
$owner = $sourceShare->getShareOwner();
try {
$ownerNode = $this->rootFolder->getUserFolder($owner)->getFirstNodeById($fileId);
} catch (NotFoundException) {
return;
}
if ($ownerNode === null) {
return;
}
$this->reshareNotificationForSharer(
$owner,
$subject,
$shareWith,
$fileId,
$this->getUserRelativePath($owner, $ownerNode->getPath()),
$fileSource instanceof File,
);
}

if ($sourceShare->getSharedBy() && $sourceShare->getSharedBy() !== $sharedBy && $sourceShare->getShareOwner() !== $sourceShare->getSharedBy()) {
$sharer = $sourceShare->getSharedBy();
try {
$sharerNode = $this->rootFolder->getUserFolder($sharer)->getFirstNodeById($fileId);
} catch (NotFoundException) {
return;
}
if ($sharerNode === null) {
return;
}

$this->reshareNotificationForSharer(
$sharer,
$subject,
$shareWith,
$fileId,
$this->getUserRelativePath($sharer, $sharerNode->getPath()),
$fileSource instanceof File,
);
if ($sourceShare->getSharedBy() && $sourceShare->getSharedBy() !== $sharedBy && $sourceShare->getShareOwner() !== $sourceShare->getSharedBy()) {
$sharer = $sourceShare->getSharedBy();
try {
$sharerNode = $this->rootFolder->getUserFolder($sharer)->getFirstNodeById($fileId);
} catch (NotFoundException) {
return;
}
if ($sharerNode === null) {
return;
}
$this->reshareNotificationForSharer(
$sharer,
$subject,
$shareWith,
$fileId,
$this->getUserRelativePath($sharer, $sharerNode->getPath()),
$fileSource instanceof File,
);
}
}

Expand Down
Loading