Updated controllers folder
This commit is contained in:
parent
6392ceef55
commit
b8b77822c2
6 changed files with 22 additions and 29 deletions
|
@ -648,7 +648,6 @@ App::get('/v1/account/sessions')
|
|||
$sessions[$index]['geo']['isoCode'] = '--';
|
||||
$sessions[$index]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$sessions[$index]['geo']['isoCode'] = '--';
|
||||
$sessions[$index]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
|
@ -732,7 +731,6 @@ App::get('/v1/account/logs')
|
|||
$output[$i]['geo']['isoCode'] = '--';
|
||||
$output[$i]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$output[$i]['geo']['isoCode'] = '--';
|
||||
$output[$i]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
|
|
|
@ -352,7 +352,7 @@ App::get('/v1/functions/:functionId/tags/:tagId')
|
|||
|
||||
$tag = $projectDB->getDocument($tagId);
|
||||
|
||||
if($tag->getAttribute('functionId') !== $function->getId()) {
|
||||
if ($tag->getAttribute('functionId') !== $function->getId()) {
|
||||
throw new Exception('Tag not found', 404);
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ App::delete('/v1/functions/:functionId/tags/:tagId')
|
|||
|
||||
$tag = $projectDB->getDocument($tagId);
|
||||
|
||||
if($tag->getAttribute('functionId') !== $function->getId()) {
|
||||
if ($tag->getAttribute('functionId') !== $function->getId()) {
|
||||
throw new Exception('Tag not found', 404);
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,7 @@ App::post('/v1/functions/:functionId/executions')
|
|||
|
||||
$tag = $projectDB->getDocument($function->getAttribute('tag'));
|
||||
|
||||
if($tag->getAttribute('functionId') !== $function->getId()) {
|
||||
if ($tag->getAttribute('functionId') !== $function->getId()) {
|
||||
throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404);
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,7 @@ App::post('/v1/functions/:functionId/executions')
|
|||
throw new Exception('Failed saving execution to DB', 500);
|
||||
}
|
||||
|
||||
if((bool)$async) {
|
||||
if ((bool)$async) {
|
||||
// Issue a TLS certificate when domain is verified
|
||||
Resque::enqueue('v1-functions', 'FunctionsV1', [
|
||||
'projectId' => $project->getId(),
|
||||
|
@ -527,7 +527,7 @@ App::get('/v1/functions/:functionId/executions/:executionId')
|
|||
|
||||
$execution = $projectDB->getDocument($executionId);
|
||||
|
||||
if($execution->getAttribute('functionId') !== $function->getId()) {
|
||||
if ($execution->getAttribute('functionId') !== $function->getId()) {
|
||||
throw new Exception('Execution not found', 404);
|
||||
}
|
||||
|
||||
|
|
|
@ -594,7 +594,6 @@ App::patch('/v1/teams/:teamId/memberships/:inviteId/status')
|
|||
'email' => $user->getAttribute('email'),
|
||||
'name' => $user->getAttribute('name'),
|
||||
])), Response::MODEL_MEMBERSHIP);
|
||||
|
||||
}, ['request', 'response', 'user', 'projectDB', 'audits']);
|
||||
|
||||
App::delete('/v1/teams/:teamId/memberships/:inviteId')
|
||||
|
|
|
@ -279,7 +279,6 @@ App::get('/v1/users/:userId/sessions')
|
|||
$sessions[$index]['geo']['isoCode'] = '--';
|
||||
$sessions[$index]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$sessions[$index]['geo']['isoCode'] = '--';
|
||||
$sessions[$index]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
|
@ -365,14 +364,13 @@ App::get('/v1/users/:userId/logs')
|
|||
try {
|
||||
$record = $geodb->get($log['ip']);
|
||||
|
||||
if($record){
|
||||
if ($record) {
|
||||
$output[$i]['geo']['isoCode'] = \strtolower($record['country']['iso_code']);
|
||||
$output[$i]['geo']['country'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown');
|
||||
} else{
|
||||
} else {
|
||||
$output[$i]['geo']['isoCode'] = '--';
|
||||
$output[$i]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$output[$i]['geo']['isoCode'] = '--';
|
||||
$output[$i]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
|
|
|
@ -44,7 +44,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo
|
|||
|
||||
$route = $utopia->match($request);
|
||||
|
||||
if(!empty($route->getLabel('sdk.platform', [])) && empty($project->getId()) && ($route->getLabel('scope', '') !== 'public')) {
|
||||
if (!empty($route->getLabel('sdk.platform', [])) && empty($project->getId()) && ($route->getLabel('scope', '') !== 'public')) {
|
||||
throw new Exception('Missing or unknown project ID', 400);
|
||||
}
|
||||
|
||||
|
@ -99,8 +99,8 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo
|
|||
* @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers
|
||||
*/
|
||||
if (App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
|
||||
if($request->getProtocol() !== 'https') {
|
||||
return $response->redirect('https://'.$request->getHostname().$request->getURI());
|
||||
if ($request->getProtocol() !== 'https') {
|
||||
return $response->redirect('https://'.$request->getHostname().$request->getURI());
|
||||
}
|
||||
|
||||
$response->addHeader('Strict-Transport-Security', 'max-age='.(60 * 60 * 24 * 126)); // 126 days
|
||||
|
@ -126,11 +126,11 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo
|
|||
$origin = $request->getOrigin($request->getReferer(''));
|
||||
$originValidator = new Origin(\array_merge($project->getAttribute('platforms', []), $console->getAttribute('platforms', [])));
|
||||
|
||||
if(!$originValidator->isValid($origin)
|
||||
if (!$originValidator->isValid($origin)
|
||||
&& \in_array($request->getMethod(), [Request::METHOD_POST, Request::METHOD_PUT, Request::METHOD_PATCH, Request::METHOD_DELETE])
|
||||
&& $route->getLabel('origin', false) !== '*'
|
||||
&& empty($request->getHeader('x-appwrite-key', ''))) {
|
||||
throw new Exception($originValidator->getDescription(), 403);
|
||||
throw new Exception($originValidator->getDescription(), 403);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -269,7 +269,7 @@ App::shutdown(function ($utopia, $request, $response, $project, $webhooks, $audi
|
|||
|
||||
$route = $utopia->match($request);
|
||||
|
||||
if($project->getId()
|
||||
if ($project->getId()
|
||||
&& $mode !== APP_MODE_ADMIN
|
||||
&& !empty($route->getLabel('sdk.namespace', null))) { // Don't calculate console usage and admin mode
|
||||
|
||||
|
@ -305,7 +305,7 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project) {
|
|||
/** @var Utopia\View $layout */
|
||||
/** @var Appwrite\Database\Document $project */
|
||||
|
||||
if(php_sapi_name() === 'cli') {
|
||||
if (php_sapi_name() === 'cli') {
|
||||
var_dump(get_class($error));
|
||||
var_dump($error->getMessage());
|
||||
var_dump($error->getFile());
|
||||
|
@ -379,7 +379,6 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project) {
|
|||
|
||||
$response->dynamic(new Document($output),
|
||||
$utopia->isDevelopment() ? Response::MODEL_ERROR_DEV : Response::MODEL_LOCALE);
|
||||
|
||||
}, ['error', 'utopia', 'request', 'response', 'layout', 'project']);
|
||||
|
||||
App::get('/manifest.json')
|
||||
|
@ -435,25 +434,25 @@ App::get('/.well-known/acme-challenge')
|
|||
$path = \str_replace('/.well-known/acme-challenge/', '', $request->getParam('q'));
|
||||
$absolute = \realpath($base.'/.well-known/acme-challenge/'.$path);
|
||||
|
||||
if(!$base) {
|
||||
if (!$base) {
|
||||
throw new Exception('Storage error', 500);
|
||||
}
|
||||
|
||||
if(!$absolute) {
|
||||
if (!$absolute) {
|
||||
throw new Exception('Unknown path', 404);
|
||||
}
|
||||
|
||||
if(!\substr($absolute, 0, \strlen($base)) === $base) {
|
||||
if (!\substr($absolute, 0, \strlen($base)) === $base) {
|
||||
throw new Exception('Invalid path', 401);
|
||||
}
|
||||
|
||||
if(!\file_exists($absolute)) {
|
||||
if (!\file_exists($absolute)) {
|
||||
throw new Exception('Unknown path', 404);
|
||||
}
|
||||
|
||||
$content = @\file_get_contents($absolute);
|
||||
|
||||
if(!$content) {
|
||||
if (!$content) {
|
||||
throw new Exception('Failed to get contents', 500);
|
||||
}
|
||||
|
||||
|
@ -463,6 +462,6 @@ App::get('/.well-known/acme-challenge')
|
|||
include_once __DIR__ . '/shared/api.php';
|
||||
include_once __DIR__ . '/shared/web.php';
|
||||
|
||||
foreach(Config::getParam('services', []) as $service) {
|
||||
foreach (Config::getParam('services', []) as $service) {
|
||||
include_once $service['controller'];
|
||||
}
|
|
@ -385,10 +385,9 @@ App::get('/console/version')
|
|||
try {
|
||||
$version = \json_decode(@\file_get_contents(App::getEnv('_APP_HOME', 'http://localhost').'/v1/health/version'), true);
|
||||
|
||||
if($version && isset($version['version'])) {
|
||||
if ($version && isset($version['version'])) {
|
||||
return $response->json(['version' => $version['version']]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new Exception('Failed to check for a newer version', 500);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
|
|
Loading…
Reference in a new issue