repod/lib/Controller/ToplistController.php
Michel Roux 098db9f09e
All checks were successful
repod / nextcloud (push) Successful in 1m3s
repod / nodejs (push) Successful in 1m20s
Refacto API to be pseudo compatible with gpodder
2023-08-01 23:18:37 +02:00

36 lines
726 B
PHP

<?php
declare(strict_types=1);
namespace OCA\RePod\Controller;
use OCA\RePod\AppInfo\Application;
use OCA\RePod\Service\FyydService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IRequest;
class ToplistController extends Controller
{
public function __construct(
IRequest $request,
private FyydService $fyydService
) {
parent::__construct(Application::APP_ID, $request);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function index(): JSONResponse
{
try {
return new JSONResponse($this->fyydService->hot());
} catch (\Exception $e) {
return new JSONResponse([$e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR);
}
}
}