1
0
Fork 0
mirror of synced 2024-06-29 11:40:45 +12:00

Cleaned up unused vars

This commit is contained in:
Eldad Fux 2020-09-11 09:05:21 +03:00
parent 4438be0627
commit 76dfa75318
3 changed files with 19 additions and 23 deletions

View file

@ -41,12 +41,11 @@ App::post('/v1/account')
->param('email', '', function () { return new Email(); }, 'User email.')
->param('password', '', function () { return new Password(); }, 'User password. Must be between 6 to 32 chars.')
->param('name', '', function () { return new Text(128); }, 'User name. Max length: 128 chars.', true)
->action(function ($email, $password, $name, $request, $response, $project, $projectDB, $webhooks, $audits) {
->action(function ($email, $password, $name, $request, $response, $project, $projectDB, $audits) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $project */
/** @var Appwrite\Database\Database $projectDB */
/** @var Appwrite\Event\Event $webhooks */
/** @var Appwrite\Event\Event $audits */
if ('console' === $project->getId()) {
@ -119,7 +118,7 @@ App::post('/v1/account')
$response->setStatusCode(Response::STATUS_CODE_CREATED);
$response->dynamic($user, Response::MODEL_USER);
}, ['request', 'response', 'project', 'projectDB', 'webhooks', 'audits']);
}, ['request', 'response', 'project', 'projectDB', 'audits']);
App::post('/v1/account/sessions')
->desc('Create Account Session')
@ -134,13 +133,12 @@ App::post('/v1/account/sessions')
->label('abuse-key', 'url:{url},email:{param-email}')
->param('email', '', function () { return new Email(); }, 'User email.')
->param('password', '', function () { return new Password(); }, 'User password. Must be between 6 to 32 chars.')
->action(function ($email, $password, $request, $response, $projectDB, $locale, $geodb, $webhooks, $audits) {
->action(function ($email, $password, $request, $response, $projectDB, $locale, $geodb, $audits) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
/** @var Utopia\Locale\Locale $locale */
/** @var GeoIp2\Database\Reader $geodb */
/** @var Appwrite\Event\Event $webhooks */
/** @var Appwrite\Event\Event $audits */
$protocol = $request->getProtocol();
@ -255,7 +253,7 @@ App::post('/v1/account/sessions')
;
$response->dynamic($session, Response::MODEL_SESSION);
}, ['request', 'response', 'projectDB', 'locale', 'geodb', 'webhooks', 'audits']);
}, ['request', 'response', 'projectDB', 'locale', 'geodb', 'audits']);
App::get('/v1/account/sessions/oauth2/:provider')
->desc('Create Account Session with OAuth2')

View file

@ -34,10 +34,9 @@ App::post('/v1/database/collections')
->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->param('rules', [], function ($projectDB) { return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES], ['$collection' => Database::SYSTEM_COLLECTION_RULES, '$permissions' => ['read' => [], 'write' => []]])); }, 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation.', false, ['projectDB'])
->action(function ($name, $read, $write, $rules, $response, $projectDB, $webhooks, $audits) {
->action(function ($name, $read, $write, $rules, $response, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
/** @var Appwrite\Event\Event $webhooks */
/** @var Appwrite\Event\Event $audits */
$parsedRules = [];
@ -85,7 +84,7 @@ App::post('/v1/database/collections')
$response->setStatusCode(Response::STATUS_CODE_CREATED);
$response->dynamic($data, Response::MODEL_COLLECTION);
}, ['response', 'projectDB', 'webhooks', 'audits']);
}, ['response', 'projectDB', 'audits']);
App::get('/v1/database/collections')
->desc('List Collections')
@ -157,10 +156,9 @@ App::put('/v1/database/collections/:collectionId')
->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions(/docs/permissions) and get a full list of available permissions.')
->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->param('rules', [], function ($projectDB) { return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES], ['$collection' => Database::SYSTEM_COLLECTION_RULES, '$permissions' => ['read' => [], 'write' => []]])); }, 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation.', true, ['projectDB'])
->action(function ($collectionId, $name, $read, $write, $rules, $response, $projectDB, $webhooks, $audits) {
->action(function ($collectionId, $name, $read, $write, $rules, $response, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
/** @var Appwrite\Event\Event $webhooks */
/** @var Appwrite\Event\Event $audits */
$collection = $projectDB->getDocument($collectionId, false);
@ -211,7 +209,7 @@ App::put('/v1/database/collections/:collectionId')
;
$response->dynamic($collection, Response::MODEL_COLLECTION);
}, ['response', 'projectDB', 'webhooks', 'audits']);
}, ['response', 'projectDB', 'audits']);
App::delete('/v1/database/collections/:collectionId')
->desc('Delete Collection')
@ -268,10 +266,9 @@ App::post('/v1/database/collections/:collectionId/documents')
->param('parentDocument', '', function () { return new UID(); }, 'Parent document unique ID. Use when you want your new document to be a child of a parent document.', true)
->param('parentProperty', '', function () { return new Key(); }, 'Parent document property name. Use when you want your new document to be a child of a parent document.', true)
->param('parentPropertyType', Document::SET_TYPE_ASSIGN, function () { return new WhiteList([Document::SET_TYPE_ASSIGN, Document::SET_TYPE_APPEND, Document::SET_TYPE_PREPEND], true); }, 'Parent document property connection type. You can set this value to **assign**, **append** or **prepend**, default value is assign. Use when you want your new document to be a child of a parent document.', true)
->action(function ($collectionId, $data, $read, $write, $parentDocument, $parentProperty, $parentPropertyType, $response, $projectDB, $webhooks, $audits) {
->action(function ($collectionId, $data, $read, $write, $parentDocument, $parentProperty, $parentPropertyType, $response, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
/** @var Appwrite\Event\Event $webhooks */
/** @var Appwrite\Event\Event $audits */
$data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array
@ -366,7 +363,7 @@ App::post('/v1/database/collections/:collectionId/documents')
;
$response->dynamic($data, Response::MODEL_ANY);
}, ['response', 'projectDB', 'webhooks', 'audits']);
}, ['response', 'projectDB', 'audits']);
App::get('/v1/database/collections/:collectionId/documents')
->desc('List Documents')
@ -465,10 +462,9 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId')
->param('data', [], function () { return new JSON(); }, 'Document data as JSON object.')
->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->action(function ($collectionId, $documentId, $data, $read, $write, $response, $projectDB, $webhooks, $audits) {
->action(function ($collectionId, $documentId, $data, $read, $write, $response, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
/** @var Appwrite\Event\Event $webhooks */
/** @var Appwrite\Event\Event $audits */
$collection = $projectDB->getDocument($collectionId, false);
@ -524,7 +520,7 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId')
;
$response->dynamic($data, Response::MODEL_ANY);
}, ['response', 'projectDB', 'webhooks', 'audits']);
}, ['response', 'projectDB', 'audits']);
App::delete('/v1/database/collections/:collectionId/documents/:documentId')
->desc('Delete Document')

View file

@ -37,12 +37,11 @@ App::post('/v1/storage/files')
->param('file', [], function () { return new File(); }, 'Binary file.', false)
->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->action(function ($file, $read, $write, $request, $response, $user, $projectDB, $webhooks, $audits, $usage) {
->action(function ($file, $read, $write, $request, $response, $user, $projectDB, $audits, $usage) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $user */
/** @var Appwrite\Database\Database $projectDB */
/** @var Appwrite\Event\Event $webhooks */
/** @var Appwrite\Event\Event $audits */
/** @var Appwrite\Event\Event $usage */
@ -152,7 +151,7 @@ App::post('/v1/storage/files')
$response->setStatusCode(Response::STATUS_CODE_CREATED);
$response->dynamic($file, Response::MODEL_FILE);
}, ['request', 'response', 'user', 'projectDB', 'webhooks', 'audits', 'usage']);
}, ['request', 'response', 'user', 'projectDB', 'audits', 'usage']);
App::get('/v1/storage/files')
->desc('List Files')
@ -476,10 +475,9 @@ App::put('/v1/storage/files/:fileId')
->param('fileId', '', function () { return new UID(); }, 'File unique ID.')
->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->action(function ($fileId, $read, $write, $response, $projectDB, $webhooks, $audits) {
->action(function ($fileId, $read, $write, $response, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
/** @var Appwrite\Event\Event $webhooks */
/** @var Appwrite\Event\Event $audits */
$file = $projectDB->getDocument($fileId);
@ -548,6 +546,10 @@ App::delete('/v1/storage/files/:fileId')
->setParam('storage', $file->getAttribute('size', 0) * -1)
;
$webhooks
->setParam('payload', $response->output($file, Response::MODEL_FILE))
;
$response->noContent();
}, ['response', 'projectDB', 'webhooks', 'audits', 'usage']);