From 7af24abcc981ed422f5a4effee8032bd0dececa6 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Thu, 3 Aug 2023 22:27:10 -0700 Subject: [PATCH] api: revert OCS API change Signed-off-by: Varun Patil --- lib/Controller/GenericApiController.php | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/lib/Controller/GenericApiController.php b/lib/Controller/GenericApiController.php index 572023c7..cf68732f 100644 --- a/lib/Controller/GenericApiController.php +++ b/lib/Controller/GenericApiController.php @@ -27,9 +27,7 @@ use OCA\Memories\AppInfo\Application; use OCA\Memories\Db\FsManager; use OCA\Memories\Db\TimelineQuery; use OCP\App\IAppManager; -use OCP\AppFramework\Http\DataResponse; -use OCP\AppFramework\Http\JSONResponse; -use OCP\AppFramework\OCSController; +use OCP\AppFramework\ApiController; use OCP\Files\IRootFolder; use OCP\IConfig; use OCP\IDBConnection; @@ -37,7 +35,7 @@ use OCP\IRequest; use OCP\IUserSession; use Psr\Log\LoggerInterface; -abstract class GenericApiController extends OCSController +abstract class GenericApiController extends ApiController { protected IConfig $config; protected IUserSession $userSession; @@ -70,22 +68,4 @@ abstract class GenericApiController extends OCSController $this->timelineQuery = $timelineQuery; $this->fs = $fs; } - - /** - * We need to extend OCSController instead of ApiController because - * these are external APIs and should be accessible without CSRF - * tokens. The OCS response, unfortunately, nukes status codes so - * we need to override the buildResponse method to force it back. - * - * @param mixed $response Response that cannot be rendered directly - * @param mixed $format Format of the response - */ - public function buildResponse($response, $format = 'json') - { - if ($response instanceof DataResponse) { - return new JSONResponse($response->getData(), $response->getStatus()); - } - - return new JSONResponse($response); - } }