@@ -88,6 +88,7 @@ protected function setUp(): void {
8888 $ this ->view ->file_put_contents ('container/shareddir/subdir/another.txt ' , $ textData );
8989 $ this ->view ->file_put_contents ('container/shareddir/subdir/another too.txt ' , $ textData );
9090 $ this ->view ->file_put_contents ('container/shareddir/subdir/not a text file.xml ' , '<xml></xml> ' );
91+ $ this ->view ->file_put_contents ('simplefile.txt ' , $ textData );
9192
9293 [$ this ->ownerStorage ,] = $ this ->view ->resolvePath ('' );
9394 $ this ->ownerCache = $ this ->ownerStorage ->getCache ();
@@ -302,6 +303,42 @@ public function testGetFolderContentsInSubdir() {
302303 );
303304 }
304305
306+ /**
307+ * This covers a bug where the share owners name was propagated
308+ * to the recipient in the recent files API response where the
309+ * share recipient has a different target set
310+ *
311+ * https://github.com/nextcloud/server/issues/39879
312+ */
313+ public function testShareRenameOriginalFileInRecentResults () {
314+ self ::loginHelper (self ::TEST_FILES_SHARING_API_USER1 );
315+
316+ $ rootFolder = \OC ::$ server ->getUserFolder (self ::TEST_FILES_SHARING_API_USER1 );
317+ $ node = $ rootFolder ->get ('simplefile.txt ' );
318+ $ share = $ this ->shareManager ->newShare ();
319+ $ share ->setNode ($ node )
320+ ->setShareType (IShare::TYPE_USER )
321+ ->setSharedWith (self ::TEST_FILES_SHARING_API_USER3 )
322+ ->setSharedBy (self ::TEST_FILES_SHARING_API_USER1 )
323+ ->setPermissions (\OCP \Constants::PERMISSION_READ );
324+ $ share = $ this ->shareManager ->createShare ($ share );
325+ $ share ->setStatus (IShare::STATUS_ACCEPTED );
326+ $ this ->shareManager ->updateShare ($ share );
327+
328+ self ::loginHelper (self ::TEST_FILES_SHARING_API_USER1 );
329+ $ node ->move (self ::TEST_FILES_SHARING_API_USER1 . '/files/simplefile2.txt ' );
330+
331+ self ::loginHelper (self ::TEST_FILES_SHARING_API_USER3 );
332+ $ rootFolder = \OC ::$ server ->getUserFolder (self ::TEST_FILES_SHARING_API_USER3 );
333+ $ recents = $ rootFolder ->getRecent (10 );
334+ self ::assertEquals ([
335+ 'welcome.txt ' ,
336+ 'simplefile.txt '
337+ ], array_map (function ($ node ) {
338+ return $ node ->getFileInfo ()['name ' ];
339+ }, $ recents ));
340+ }
341+
305342 public function testGetFolderContentsWhenSubSubdirShared () {
306343 self ::loginHelper (self ::TEST_FILES_SHARING_API_USER1 );
307344
0 commit comments