From 6d2d115fd33408cf32edbfa6bcf857f7c5300020 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 25 Aug 2022 09:56:37 +0300 Subject: [PATCH] addressing comments --- app/controllers/api/videos.php | 3 +-- app/init.php | 4 ++-- app/workers/transcoding.php | 1 - .../Services/Videos/VideoCustomServerTest.php | 16 +++++++++++++++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/videos.php b/app/controllers/api/videos.php index cab26bda87..555360140b 100644 --- a/app/controllers/api/videos.php +++ b/app/controllers/api/videos.php @@ -226,7 +226,6 @@ App::get('/v1/videos') ->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_VIDEO) - ->param('videoId', '', new UID(), 'Video unique ID.') ->param('limit', 25, new Range(0, 100), 'Maximum number of files to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) ->param('offset', 0, new Range(0, APP_LIMIT_COUNT), 'Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true) ->param('cursor', '', new UID(), 'ID of the file used as the starting point for the query, excluding the file itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)', true) @@ -234,7 +233,7 @@ App::get('/v1/videos') ->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true) ->inject('response') ->inject('dbForProject') - ->action(function (string $videoId, int $limit, int $offset, string $cursor, string $cursorDirection, string $orderType, Response $response, Database $dbForProject) { + ->action(function (int $limit, int $offset, string $cursor, string $cursorDirection, string $orderType, Response $response, Database $dbForProject) { if (!empty($cursor)) { $cursorFile = $dbForProject->getDocument('videos', $cursor); diff --git a/app/init.php b/app/init.php index 27f04d272b..33f04fea1e 100644 --- a/app/init.php +++ b/app/init.php @@ -844,8 +844,8 @@ App::setResource('project', function ($dbForConsole, $request, $console) { /** @var Utopia\Database\Database $dbForConsole */ /** @var Utopia\Database\Document $console */ - $projectId = 'dev'; - //$projectId = $request->getParam('project', $request->getHeader('x-appwrite-project', 'console')); + //$projectId = 'dev'; + $projectId = $request->getParam('project', $request->getHeader('x-appwrite-project', 'console')); if ($projectId === 'console') { return $console; diff --git a/app/workers/transcoding.php b/app/workers/transcoding.php index 26d62a149a..70b05f0f95 100644 --- a/app/workers/transcoding.php +++ b/app/workers/transcoding.php @@ -56,7 +56,6 @@ class TranscodingV1 extends Worker return "Transcoding"; } - public function init(): void { diff --git a/tests/e2e/Services/Videos/VideoCustomServerTest.php b/tests/e2e/Services/Videos/VideoCustomServerTest.php index ea82d49070..9deb91b8fe 100644 --- a/tests/e2e/Services/Videos/VideoCustomServerTest.php +++ b/tests/e2e/Services/Videos/VideoCustomServerTest.php @@ -525,7 +525,7 @@ class VideoCustomServerTest extends Scope 'x-appwrite-key' => $this->getProject()['apiKey'], ]); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals(1506, strlen($response['body'])); + $this->assertEquals(1508, strlen($response['body'])); $response = $this->client->call(Client::METHOD_GET, '/videos/' . $videoId . '/streams/dash', [ 'content-type' => 'application/json', @@ -829,4 +829,18 @@ class VideoCustomServerTest extends Scope $this->assertTrue($isVideo); $this->assertTrue($isAudio); } + + + public function testGetVideos() + { + $response = $this->client->call(Client::METHOD_GET, '/videos', [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ]); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertGreaterThan(0, $response['body']['total']); + $this->assertGreaterThan(0, count($response['body']['videos'])); + } }