Newer
Older
* @copyright 2021 Jonas Heinrich <onny@project-insanity.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
use OCA\Podcast\Service\FyydApiService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
class ShowController extends Controller {
/** @var FyydApiService */
private $fyydapi;
/** @var string */
private $userId;
use Errors;
public function __construct(IRequest $request,
$userId) {
parent::__construct(Application::APP_ID, $request);
$this->service = $service;
$this->userId = $userId;
}
/**
* @NoAdminRequired
*/
public function index(int $podcast_id = null, string $category = null,
int $count = 20, int $page = 0): DataResponse {
$data = $this->service->findAll($this->userId);
$list = $this->fyydapi->queryCategory($category, $count, $page);
return new DataResponse($list);
$list = $this->fyydapi->queryPodcast($podcast_id);
foreach($data as $localEpisode) {
$list['data']['dateadded'] = $localEpisode->getDateadded();
}
}
return new DataResponse($list);
$data = array_slice($data, $page * $count, $count);
$nextPage = $page + 1;
} else {
$nextPage = null;
};
$response = [
"meta" => [
"paging" => [
"next_page" => $nextPage,
],
],
"data" => $data,
];
return new DataResponse($response);
}
/**
* @NoAdminRequired
*/
public function show(int $id): DataResponse {
return $this->handleNotFound(function () use ($id) {
return $this->service->find($id, $this->userId);
});
}
/**
* @NoAdminRequired
*/
public function create(int $id, string $smallImageURL, string $author,
string $title, string $lastpub, int $dateadded, string $homepage,
string $feedurl): DataResponse {
return new DataResponse($this->service->create($id, $smallImageURL, $author,
$title, $lastpub, $dateadded, $homepage, $feedurl, $this->userId));
public function update(int $id, string $smallImageURL, string $author,
string $title, string $lastpub, int $dateadded, string $homepage,
string $feedurl): DataResponse {
return $this->handleNotFound(function () use ($id, $smallImageURL, $author,
$title, $lastpub, $dateadded, $homepage, $feedurl) {
return $this->service->update($id, $smallImageURL, $author, $title, $lastpub,
$dateadded, $homepage, $feedurl, $this->userId);