mirror of
https://github.com/appwrite/appwrite
synced 2026-05-22 08:28:42 +00:00
Merge pull request #2829 from appwrite/feat-update-request-filters
Update Request Filters for 0.13
This commit is contained in:
commit
8fd0a9cd31
3 changed files with 44 additions and 1 deletions
|
|
@ -999,7 +999,6 @@ App::get('/v1/functions/:functionId/executions')
|
|||
|
||||
$function = Authorization::skip(fn() => $dbForProject->getDocument('functions', $functionId));
|
||||
|
||||
throw new Exception('Function not found', 404, Exception::FUNCTION_NOT_FOUND);
|
||||
if ($function->isEmpty()) {
|
||||
throw new Exception('Function not found', 404, Exception::FUNCTION_NOT_FOUND);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use Utopia\Database\Document;
|
|||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Appwrite\Utopia\Request\Filters\V12 as RequestV12;
|
||||
use Appwrite\Utopia\Request\Filters\V13 as RequestV13;
|
||||
use Utopia\Validator\Text;
|
||||
|
||||
Config::setParam('domainVerification', false);
|
||||
|
|
@ -49,6 +50,9 @@ App::init(function ($utopia, $request, $response, $console, $project, $dbForCons
|
|||
case version_compare ($requestFormat , '0.12.0', '<') :
|
||||
Request::setFilter(new RequestV12());
|
||||
break;
|
||||
case version_compare ($requestFormat , '0.13.0', '<') :
|
||||
Request::setFilter(new RequestV13());
|
||||
break;
|
||||
default:
|
||||
Request::setFilter(null);
|
||||
}
|
||||
|
|
|
|||
40
src/Appwrite/Utopia/Request/Filters/V13.php
Normal file
40
src/Appwrite/Utopia/Request/Filters/V13.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Request\Filters;
|
||||
|
||||
use Appwrite\Utopia\Request\Filter;
|
||||
|
||||
class V13 extends Filter
|
||||
{
|
||||
// Convert 0.12 params format to 0.13 format
|
||||
public function parse(array $content, string $model): array
|
||||
{
|
||||
switch ($model) {
|
||||
// Replaced Types
|
||||
case "database.createFloatAttribute":
|
||||
$content = $this->converStringToNum($content, "min");
|
||||
$content = $this->converStringToNum($content, "max");
|
||||
$content = $this->converStringToNum($content, "default");
|
||||
break;
|
||||
case "database.createIntegerAttribute":
|
||||
$content = $this->converStringToNum($content, "min");
|
||||
$content = $this->converStringToNum($content, "max");
|
||||
$content = $this->converStringToNum($content, "default");
|
||||
break;
|
||||
case "functions.createExecution":
|
||||
$content = $this->convertExecution($content);
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
private function converStringToNum($content, $value) {
|
||||
$content[$value] = (int) $content[$value];
|
||||
return $content;
|
||||
}
|
||||
|
||||
private function convertExecution($content) {
|
||||
$content['async'] = true;
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue