mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Merge remote-tracking branch 'origin/master' into feat-usage-refactor
This commit is contained in:
@@ -337,7 +337,7 @@ class Auth
|
||||
$token->isSet('secret') &&
|
||||
$token->isSet('expire') &&
|
||||
$token->getAttribute('type') == Auth::TOKEN_TYPE_PHONE &&
|
||||
$token->getAttribute('secret') === $secret &&
|
||||
$token->getAttribute('secret') === self::hash($secret) &&
|
||||
DateTime::formatTz($token->getAttribute('expire')) >= DateTime::formatTz(DateTime::now())
|
||||
) {
|
||||
return (string) $token->getId();
|
||||
|
||||
@@ -12,7 +12,7 @@ class Exception extends \Exception
|
||||
* Naming the error types based on the following convention
|
||||
* <ENTITY>_<ERROR_TYPE>
|
||||
*
|
||||
* Appwrite has the follwing entities:
|
||||
* Appwrite has the following entities:
|
||||
* - General
|
||||
* - Users
|
||||
* - Teams
|
||||
|
||||
@@ -44,6 +44,7 @@ abstract class Migration
|
||||
'1.0.0-RC1' => 'V15',
|
||||
'1.0.0' => 'V15',
|
||||
'1.0.1' => 'V15',
|
||||
'1.0.3' => 'V15'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -504,6 +504,7 @@ class V15 extends Migration
|
||||
$this->createPermissionsColumn($id);
|
||||
$this->migrateDateTimeAttribute($id, '_createdAt');
|
||||
$this->migrateDateTimeAttribute($id, '_updatedAt');
|
||||
$this->migrateDateTimeAttribute($id, 'time');
|
||||
break;
|
||||
|
||||
case 'buckets':
|
||||
|
||||
@@ -49,11 +49,17 @@ class URL extends Validator
|
||||
*/
|
||||
public function isValid($value): bool
|
||||
{
|
||||
if (\filter_var($value, FILTER_VALIDATE_URL) === false) {
|
||||
$sanitizedURL = '';
|
||||
|
||||
foreach (str_split($value) as $character) {
|
||||
$sanitizedURL .= (ord($character) > 127) ? rawurlencode($character) : $character;
|
||||
}
|
||||
|
||||
if (\filter_var($sanitizedURL, FILTER_VALIDATE_URL) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($this->allowedSchemes) && !\in_array(\parse_url($value, PHP_URL_SCHEME), $this->allowedSchemes)) {
|
||||
if (!empty($this->allowedSchemes) && !\in_array(\parse_url($sanitizedURL, PHP_URL_SCHEME), $this->allowedSchemes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,13 @@ namespace Appwrite\SMS\Adapter;
|
||||
|
||||
use Appwrite\SMS\Adapter;
|
||||
|
||||
// Mock adapter used to E2E test worker
|
||||
class Mock extends Adapter
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public static string $digits = '123456';
|
||||
private string $endpoint = 'http://request-catcher:5000/mock-sms';
|
||||
|
||||
/**
|
||||
* @param string $from
|
||||
@@ -19,6 +20,19 @@ class Mock extends Adapter
|
||||
*/
|
||||
public function send(string $from, string $to, string $message): void
|
||||
{
|
||||
return;
|
||||
$this->request(
|
||||
method: 'POST',
|
||||
url: $this->endpoint,
|
||||
payload: \json_encode([
|
||||
'message' => $message,
|
||||
'from' => $from,
|
||||
'to' => $to
|
||||
]),
|
||||
headers: [
|
||||
"content-type: application/json",
|
||||
"x-username: {$this->user}",
|
||||
"x-key: {$this->secret}",
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,20 +91,17 @@ class V15 extends Filter
|
||||
$parsedResponse[$listKey] = array_map(fn ($content) => $this->parseCreatedAtUpdatedAt($content), $parsedResponse[$listKey]);
|
||||
break;
|
||||
case Response::MODEL_DOCUMENT:
|
||||
$parsedResponse = $this->parseDocument($parsedResponse);
|
||||
break;
|
||||
case Response::MODEL_FILE:
|
||||
$parsedResponse = $this->parsePermissionsCreatedAtUpdatedAt($parsedResponse);
|
||||
break;
|
||||
case Response::MODEL_DOCUMENT_LIST:
|
||||
$listKey = 'documents';
|
||||
$parsedResponse[$listKey] = array_map(fn ($content) => $this->parseDocument($content), $parsedResponse[$listKey]);
|
||||
break;
|
||||
case Response::MODEL_FILE_LIST:
|
||||
$listKey = '';
|
||||
switch ($model) {
|
||||
case Response::MODEL_DOCUMENT_LIST:
|
||||
$listKey = 'documents';
|
||||
break;
|
||||
case Response::MODEL_FILE_LIST:
|
||||
$listKey = 'files';
|
||||
break;
|
||||
}
|
||||
$listKey = 'files';
|
||||
$parsedResponse[$listKey] = array_map(fn ($content) => $this->parsePermissionsCreatedAtUpdatedAt($content), $parsedResponse[$listKey]);
|
||||
break;
|
||||
case Response::MODEL_EXECUTION:
|
||||
@@ -210,7 +207,11 @@ class V15 extends Filter
|
||||
protected function parseDatetimeAttributes(array $content, array $attributes): array
|
||||
{
|
||||
foreach ($attributes as $attribute) {
|
||||
if (isset($content[$attribute])) {
|
||||
if (array_key_exists($attribute, $content)) {
|
||||
if (empty($content[$attribute])) {
|
||||
$content[$attribute] = 0;
|
||||
continue;
|
||||
}
|
||||
$content[$attribute] = strtotime($content[$attribute]);
|
||||
}
|
||||
}
|
||||
@@ -314,6 +315,19 @@ class V15 extends Filter
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseDocument(array $content)
|
||||
{
|
||||
if (isset($content['$collectionId'])) {
|
||||
$content['$collection'] = $content['$collectionId'];
|
||||
unset($content['$collectionId']);
|
||||
}
|
||||
|
||||
unset($content['$databaseId']);
|
||||
|
||||
$content = $this->parsePermissionsCreatedAtUpdatedAt($content);
|
||||
return $content;
|
||||
}
|
||||
|
||||
private function parseExecution($content)
|
||||
{
|
||||
unset($content['stdout']);
|
||||
|
||||
@@ -13,26 +13,26 @@ class AlgoScrypt extends Model
|
||||
->addRule('costCpu', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'CPU complexity of computed hash.',
|
||||
'default' => '',
|
||||
'default' => 8,
|
||||
'example' => 8,
|
||||
])
|
||||
->addRule('costMemory', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Memory complexity of computed hash.',
|
||||
'default' => '',
|
||||
'default' => 14,
|
||||
'example' => 14,
|
||||
])
|
||||
->addRule('costParallel', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Parallelization of computed hash.',
|
||||
'default' => '',
|
||||
'default' => 1,
|
||||
'example' => 1,
|
||||
])
|
||||
->addRule('length', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Length used to compute hash.',
|
||||
'default' => '',
|
||||
'example' => 1,
|
||||
'default' => 64,
|
||||
'example' => 64,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user