diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index f61b9dac58afe..e33f93e8ce6c5 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -208,9 +208,13 @@ protected function formatShare(\OCP\Share\IShare $share, Node $recipientNode = n $result['share_with_displayname'] = $group !== null ? $group->getDisplayName() : $share->getSharedWith(); } else if ($share->getShareType() === Share::SHARE_TYPE_LINK) { + // "share_with" and "share_with_displayname" for passwords of link + // shares was deprecated in Nextcloud 15, use "password" instead. $result['share_with'] = $share->getPassword(); $result['share_with_displayname'] = $share->getPassword(); + $result['password'] = $share->getPassword(); + $result['send_password_by_talk'] = $share->getSendPasswordByTalk(); $result['token'] = $share->getToken(); diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index efc252d49d72a..67130c01eb509 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -428,6 +428,7 @@ public function dataGetShare() { $expected = [ 'id' => 101, 'share_type' => \OCP\Share::SHARE_TYPE_LINK, + 'password' => 'password', 'share_with' => 'password', 'share_with_displayname' => 'password', 'send_password_by_talk' => false, @@ -2687,6 +2688,7 @@ public function dataFormatShare() { 'file_source' => 3, 'file_parent' => 1, 'file_target' => 'myTarget', + 'password' => 'mypassword', 'share_with' => 'mypassword', 'share_with_displayname' => 'mypassword', 'send_password_by_talk' => false, @@ -2736,6 +2738,7 @@ public function dataFormatShare() { 'file_source' => 3, 'file_parent' => 1, 'file_target' => 'myTarget', + 'password' => 'mypassword', 'share_with' => 'mypassword', 'share_with_displayname' => 'mypassword', 'send_password_by_talk' => true,