api: revert OCS API change
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/767/head
parent
c7b05c1194
commit
7af24abcc9
|
@ -27,9 +27,7 @@ use OCA\Memories\AppInfo\Application;
|
||||||
use OCA\Memories\Db\FsManager;
|
use OCA\Memories\Db\FsManager;
|
||||||
use OCA\Memories\Db\TimelineQuery;
|
use OCA\Memories\Db\TimelineQuery;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\ApiController;
|
||||||
use OCP\AppFramework\Http\JSONResponse;
|
|
||||||
use OCP\AppFramework\OCSController;
|
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
|
@ -37,7 +35,7 @@ use OCP\IRequest;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
abstract class GenericApiController extends OCSController
|
abstract class GenericApiController extends ApiController
|
||||||
{
|
{
|
||||||
protected IConfig $config;
|
protected IConfig $config;
|
||||||
protected IUserSession $userSession;
|
protected IUserSession $userSession;
|
||||||
|
@ -70,22 +68,4 @@ abstract class GenericApiController extends OCSController
|
||||||
$this->timelineQuery = $timelineQuery;
|
$this->timelineQuery = $timelineQuery;
|
||||||
$this->fs = $fs;
|
$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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue