Skip to content

Commit 3c6b4dd

Browse files
committed
fix: Fix handling of deleting share from self
If a share is deleted from self and it is not a group share it was handled as a user share. However, other types of shares can be deleted from self (for example, circle or room shares), so user shares need to be explicitly checked. Note that as those other share types are not explicitly handled no entry is added to the activity for them, but that was already the case before (this change just prevents an exception to be thrown). Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
1 parent a8fd0e7 commit 3c6b4dd

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/FilesHooks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ public function unShareSelf(IShare $share) {
826826
if (in_array($share->getNodeType(), ['file', 'folder'], true)) {
827827
if ($share->getShareType() === IShare::TYPE_GROUP) {
828828
$this->unshareFromSelfGroup($share);
829-
} else {
829+
} elseif ($share->getShareType() === IShare::TYPE_USER) {
830830
$this->unshareFromUser($share);
831831
}
832832
}

tests/FilesHooksTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,8 @@ public function testLeaveShare(): void {
962962
->willReturn('file');
963963
$share->method('getSharedWith')
964964
->willReturn('with');
965+
$share->method('getShareType')
966+
->willReturn(IShare::TYPE_USER);
965967

966968
$this->settings->expects($this->exactly(3))
967969
->method('getUserSetting')

0 commit comments

Comments
 (0)