Merge pull request #16254 from nextcloud/backport/16208/stable16

[stable16] Always set the display name for user shares
This commit is contained in:
Morris Jobke 2019-07-09 14:44:01 +02:00 committed by GitHub
commit ecf60b59ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -940,6 +940,10 @@ class DefaultShareProvider implements IShareProvider {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
$share->setSharedWith($data['share_with']);
$user = $this->userManager->get($data['share_with']);
if ($user !== null) {
$share->setSharedWithDisplayName($user->getDisplayName());
}
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
$share->setSharedWith($data['share_with']);
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {

View File

@ -1110,8 +1110,10 @@ class DefaultShareProviderTest extends \Test\TestCase {
$user0 = $this->createMock(IUser::class);
$user0->method('getUID')->willReturn('user0');
$user0->method('getDisplayName')->willReturn('user0');
$user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
$user0->method('getDisplayName')->willReturn('user0');
$this->userManager->method('get')->willReturnMap([
['user0', $user0],
@ -1640,8 +1642,10 @@ class DefaultShareProviderTest extends \Test\TestCase {
$user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
$user1->method('getDisplayName')->willReturn('user1');
$user2 = $this->createMock(IUser::class);
$user2->method('getUID')->willReturn('user2');
$user2->method('getDisplayName')->willReturn('user2');
$this->userManager->method('get')->will($this->returnValueMap([
['user1', $user1],
['user2', $user2],
@ -1691,8 +1695,10 @@ class DefaultShareProviderTest extends \Test\TestCase {
$user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
$user1->method('getDisplayName')->willReturn('user1');
$user2 = $this->createMock(IUser::class);
$user2->method('getUID')->willReturn('user2');
$user2->method('getDisplayName')->willReturn('user2');
$user3 = $this->createMock(IUser::class);
$this->userManager->method('get')->will($this->returnValueMap([
['user1', $user1],
@ -1755,6 +1761,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
for($i = 0; $i < 6; $i++) {
$user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('user'.$i);
$user->method('getDisplayName')->willReturn('user' . $i);
$users['user'.$i] = $user;
}
@ -2105,8 +2112,10 @@ class DefaultShareProviderTest extends \Test\TestCase {
$user0 = $this->createMock(IUser::class);
$user0->method('getUID')->willReturn('user0');
$user0->method('getDisplayName')->willReturn('user0');
$user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
$user1->method('getDisplayName')->willReturn('user1');
$this->userManager->method('get')->will($this->returnValueMap([
['user0', $user0],