Skip to content

Commit 2f7a1fc

Browse files
Merge pull request #34477 from nextcloud/bugfix/noid/sharee-recommendations-show-group-id
Show group name instead of group id as recommendation
2 parents 21576ff + e674087 commit 2f7a1fc

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/private/Share20/DefaultShareProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,10 @@ private function createShare($data) {
10871087
}
10881088
} elseif ($share->getShareType() === IShare::TYPE_GROUP) {
10891089
$share->setSharedWith($data['share_with']);
1090+
$group = $this->groupManager->get($data['share_with']);
1091+
if ($group !== null) {
1092+
$share->setSharedWithDisplayName($group->getDisplayName());
1093+
}
10901094
} elseif ($share->getShareType() === IShare::TYPE_LINK) {
10911095
$share->setPassword($data['password']);
10921096
$share->setSendPasswordByTalk((bool)$data['password_by_talk']);

tests/lib/Share20/DefaultShareProviderTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ public function testGetShareByIdUserGroupShare() {
365365

366366
$group0 = $this->createMock(IGroup::class);
367367
$group0->method('inGroup')->with($user1)->willReturn(true);
368+
$group0->method('getDisplayName')->willReturn('g0-displayname');
368369

369370
$node = $this->createMock(Folder::class);
370371
$node->method('getId')->willReturn(42);
@@ -1488,6 +1489,7 @@ public function testDeleteFromSelfGroupNoCustomShare() {
14881489
$group = $this->createMock(IGroup::class);
14891490
$group->method('getGID')->willReturn('group');
14901491
$group->method('inGroup')->with($user2)->willReturn(true);
1492+
$group->method('getDisplayName')->willReturn('group-displayname');
14911493
$this->groupManager->method('get')->with('group')->willReturn($group);
14921494

14931495
$file = $this->createMock(File::class);
@@ -1559,6 +1561,7 @@ public function testDeleteFromSelfGroupAlreadyCustomShare() {
15591561
$group = $this->createMock(IGroup::class);
15601562
$group->method('getGID')->willReturn('group');
15611563
$group->method('inGroup')->with($user2)->willReturn(true);
1564+
$group->method('getDisplayName')->willReturn('group-displayname');
15621565
$this->groupManager->method('get')->with('group')->willReturn($group);
15631566

15641567
$file = $this->createMock(File::class);
@@ -1616,6 +1619,7 @@ public function testDeleteFromSelfGroupUserNotInGroup() {
16161619
$group = $this->createMock(IGroup::class);
16171620
$group->method('getGID')->willReturn('group');
16181621
$group->method('inGroup')->with($user2)->willReturn(false);
1622+
$group->method('getDisplayName')->willReturn('group-displayname');
16191623
$this->groupManager->method('get')->with('group')->willReturn($group);
16201624

16211625
$file = $this->createMock(File::class);
@@ -2002,6 +2006,7 @@ function ($userId) use ($users) {
20022006
for ($i = 0; $i < 2; $i++) {
20032007
$group = $this->createMock(IGroup::class);
20042008
$group->method('getGID')->willReturn('group'.$i);
2009+
$group->method('getDisplayName')->willReturn('group-displayname' . $i);
20052010
$groups['group'.$i] = $group;
20062011
}
20072012

@@ -2080,6 +2085,7 @@ function ($userId) use ($users) {
20802085
for ($i = 0; $i < 2; $i++) {
20812086
$group = $this->createMock(IGroup::class);
20822087
$group->method('getGID')->willReturn('group'.$i);
2088+
$group->method('getDisplayName')->willReturn('group-displayname'.$i);
20832089
$groups['group'.$i] = $group;
20842090
}
20852091

@@ -2196,6 +2202,7 @@ public function testMoveGroupShare() {
21962202
$group0 = $this->createMock(IGroup::class);
21972203
$group0->method('getGID')->willReturn('group0');
21982204
$group0->method('inGroup')->with($user0)->willReturn(true);
2205+
$group0->method('getDisplayName')->willReturn('group0-displayname');
21992206

22002207
$this->groupManager->method('get')->with('group0')->willReturn($group0);
22012208

0 commit comments

Comments
 (0)