From c7961fcd32ba3ef94cf77eba9fb19424c34d9887 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 8 Oct 2022 16:05:52 +0200 Subject: [PATCH 1/2] Show group name instead of group id as recommendation Signed-off-by: Joas Schilling --- lib/private/Share20/DefaultShareProvider.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index c78cf62e069d7..a5a5568788d92 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -1087,6 +1087,10 @@ private function createShare($data) { } } elseif ($share->getShareType() === IShare::TYPE_GROUP) { $share->setSharedWith($data['share_with']); + $group = $this->groupManager->get($data['share_with']); + if ($group !== null) { + $share->setSharedWithDisplayName($group->getDisplayName()); + } } elseif ($share->getShareType() === IShare::TYPE_LINK) { $share->setPassword($data['password']); $share->setSendPasswordByTalk((bool)$data['password_by_talk']); From 86d020662604aa8deeb924e86f02a9072d2f4ada Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 12 Oct 2022 16:03:57 +0200 Subject: [PATCH 2/2] Adjust unit tests Signed-off-by: Joas Schilling --- tests/lib/Share20/DefaultShareProviderTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php index ed2bc2a4edad8..d7b5dbc9b7449 100644 --- a/tests/lib/Share20/DefaultShareProviderTest.php +++ b/tests/lib/Share20/DefaultShareProviderTest.php @@ -365,6 +365,7 @@ public function testGetShareByIdUserGroupShare() { $group0 = $this->createMock(IGroup::class); $group0->method('inGroup')->with($user1)->willReturn(true); + $group0->method('getDisplayName')->willReturn('g0-displayname'); $node = $this->createMock(Folder::class); $node->method('getId')->willReturn(42); @@ -1488,6 +1489,7 @@ public function testDeleteFromSelfGroupNoCustomShare() { $group = $this->createMock(IGroup::class); $group->method('getGID')->willReturn('group'); $group->method('inGroup')->with($user2)->willReturn(true); + $group->method('getDisplayName')->willReturn('group-displayname'); $this->groupManager->method('get')->with('group')->willReturn($group); $file = $this->createMock(File::class); @@ -1559,6 +1561,7 @@ public function testDeleteFromSelfGroupAlreadyCustomShare() { $group = $this->createMock(IGroup::class); $group->method('getGID')->willReturn('group'); $group->method('inGroup')->with($user2)->willReturn(true); + $group->method('getDisplayName')->willReturn('group-displayname'); $this->groupManager->method('get')->with('group')->willReturn($group); $file = $this->createMock(File::class); @@ -1616,6 +1619,7 @@ public function testDeleteFromSelfGroupUserNotInGroup() { $group = $this->createMock(IGroup::class); $group->method('getGID')->willReturn('group'); $group->method('inGroup')->with($user2)->willReturn(false); + $group->method('getDisplayName')->willReturn('group-displayname'); $this->groupManager->method('get')->with('group')->willReturn($group); $file = $this->createMock(File::class); @@ -2002,6 +2006,7 @@ function ($userId) use ($users) { for ($i = 0; $i < 2; $i++) { $group = $this->createMock(IGroup::class); $group->method('getGID')->willReturn('group'.$i); + $group->method('getDisplayName')->willReturn('group-displayname' . $i); $groups['group'.$i] = $group; } @@ -2080,6 +2085,7 @@ function ($userId) use ($users) { for ($i = 0; $i < 2; $i++) { $group = $this->createMock(IGroup::class); $group->method('getGID')->willReturn('group'.$i); + $group->method('getDisplayName')->willReturn('group-displayname'.$i); $groups['group'.$i] = $group; } @@ -2196,6 +2202,7 @@ public function testMoveGroupShare() { $group0 = $this->createMock(IGroup::class); $group0->method('getGID')->willReturn('group0'); $group0->method('inGroup')->with($user0)->willReturn(true); + $group0->method('getDisplayName')->willReturn('group0-displayname'); $this->groupManager->method('get')->with('group0')->willReturn($group0);