apibase: fix getuserfile

pull/221/head
Varun Patil 2022-11-09 22:34:58 -08:00
parent a85b06bac0
commit 0074647b21
1 changed files with 13 additions and 1 deletions

View File

@ -134,7 +134,14 @@ class ApiBase extends Controller
return $folder;
}
protected function getUserFile(int $id): File
/**
* Get a file with ID from user's folder
*
* @param int $fileId
*
* @return File|null
*/
protected function getUserFile(int $id)
{
$user = $this->userSession->getUser();
if (null === $user) {
@ -148,6 +155,11 @@ class ApiBase extends Controller
return null;
}
// Check if node is a file
if (!($file[0] instanceof File)) {
return null;
}
return $file[0];
}