Merge branch 'main' of github.com:appwrite/appwrite into remove-cloud-scripts

This commit is contained in:
shimon committed 2024-03-06 17:58:58 +01:00
commit dfac3d585a
232 files changed
+969 -595

No files matched your search

+1 -1
View File
@@ -32,7 +32,7 @@ class Phone extends Validator
*/
public function isValid($value): bool
{
return is_string($value) && !!\preg_match('/^\+[1-9]\d{1,14}$/', $value);
return is_string($value) && !!\preg_match('/^\+[1-9]\d{6,14}$/', $value);
}
/**
+42
View File
@@ -338,6 +338,14 @@ class Mail extends Event
return $this;
}
/**
* Set attachment
* @param string $content
* @param string $filename
* @param string $encoding
* @param string $type
* @return self
*/
public function setAttachment(string $content, string $filename, string $encoding = 'base64', string $type = 'plain/text')
{
$this->attachment = [
@@ -349,11 +357,45 @@ class Mail extends Event
return $this;
}
/**
* Get attachment
*
* @return array
*/
public function getAttachment(): array
{
return $this->attachment;
}
/**
* Reset attachment
*
* @return self
*/
public function resetAttachment(): self
{
$this->attachment = [];
return $this;
}
/**
* Reset
*
* @return self
*/
public function reset(): self
{
$this->project = null;
$this->recipient = '';
$this->name = '';
$this->subject = '';
$this->body = '';
$this->variables = [];
$this->bodyTemplate = '';
$this->attachment = [];
return $this;
}
/**
* Executes the event and sends it to the mails worker.
*
+1
View File
@@ -55,6 +55,7 @@ class Exception extends \Exception
public const GENERAL_CODES_DISABLED = 'general_codes_disabled';
public const GENERAL_USAGE_DISABLED = 'general_usage_disabled';
public const GENERAL_NOT_IMPLEMENTED = 'general_not_implemented';
public const GENERAL_BAD_REQUEST = 'general_bad_request';
/** Users */
public const USER_COUNT_EXCEEDED = 'user_count_exceeded';
+9 -3
View File
@@ -7,7 +7,9 @@ use Utopia\CLI\Console;
use Utopia\Platform\Action;
use Utopia\Queue\Client;
use Utopia\Queue\Connection;
use Utopia\Validator\Integer;
use Utopia\Validator\WhiteList;
use Utopia\Validator\Wildcard;
class QueueRetry extends Action
{
@@ -35,21 +37,25 @@ class QueueRetry extends Action
Event::MIGRATIONS_QUEUE_NAME,
Event::HAMSTER_CLASS_NAME
]), 'Queue name')
->param('limit', 0, new Wildcard(), 'jobs limit', true)
->inject('queue')
->callback(fn ($name, $queue) => $this->action($name, $queue));
->callback(fn ($name, $limit, $queue) => $this->action($name, $limit, $queue));
}
/**
* @param string $name The name of the queue to retry jobs from
* @param mixed $limit
* @param Connection $queue
*/
public function action(string $name, Connection $queue): void
public function action(string $name, mixed $limit, Connection $queue): void
{
if (!$name) {
Console::error('Missing required parameter $name');
return;
}
$limit = (int)$limit;
$queueClient = new Client($name, $queue);
if ($queueClient->countFailedJobs() === 0) {
@@ -59,6 +65,6 @@ class QueueRetry extends Action
Console::log('Retrying failed jobs...');
$queueClient->retry();
$queueClient->retry($limit);
}
}
+1 -1
View File
@@ -74,7 +74,7 @@ class SDKs extends Action
$spec = file_get_contents(__DIR__ . '/../../../../app/config/specs/swagger2-' . $version . '-' . $language['family'] . '.json');
$cover = 'https://appwrite.io/images/github.png';
$cover = 'https://github.com/appwrite/appwrite/raw/main/public/images/github.png';
$result = \realpath(__DIR__ . '/../../../../app') . '/sdks/' . $key . '-' . $language['key'];
$resultExamples = \realpath(__DIR__ . '/../../../..') . '/docs/examples/' . $version . '/' . $key . '-' . $language['key'];
$target = \realpath(__DIR__ . '/../../../../app') . '/sdks/git/' . $language['key'] . '/';
+23 -8
View File
@@ -88,14 +88,29 @@ class Messaging extends Action
return;
}
$sms = match ($this->dsn->getHost()) {
'mock' => new Mock($this->user, $this->secret), // used for tests
'twilio' => new Twilio($this->user, $this->secret),
'text-magic' => new TextMagic($this->user, $this->secret),
'telesign' => new Telesign($this->user, $this->secret),
'msg91' => new Msg91($this->user, $this->secret),
'vonage' => new Vonage($this->user, $this->secret),
default => null
switch ($this->dsn->getHost()) {
case 'mock':
$sms = new Mock($this->user, $this->secret); // used for tests
break;
case 'twilio':
$sms = new Twilio($this->user, $this->secret);
break;
case 'text-magic':
$sms = new TextMagic($this->user, $this->secret);
break;
case 'telesign':
$sms = new Telesign($this->user, $this->secret);
break;
case 'msg91':
$sms = new Msg91($this->user, $this->secret);
$sms->setTemplate($this->dsn->getParam('template'));
break;
case 'vonage':
$sms = new Vonage($this->user, $this->secret);
break;
default:
$sms = null;
};
if (empty(App::getEnv('_APP_SMS_PROVIDER'))) {
@@ -295,7 +295,7 @@ class OpenAPI3 extends Format
switch ((!empty($validator)) ? \get_class($validator) : '') {
case 'Utopia\Validator\Text':
$node['schema']['type'] = $validator->getType();
$node['schema']['x-example'] = '<' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . '>';
$node['schema']['x-example'] = '[' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . ']';
break;
case 'Utopia\Validator\Boolean':
$node['schema']['type'] = $validator->getType();
@@ -303,14 +303,14 @@ class OpenAPI3 extends Format
break;
case 'Utopia\Database\Validator\UID':
$node['schema']['type'] = $validator->getType();
$node['schema']['x-example'] = '<' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . '>';
$node['schema']['x-example'] = '[' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . ']';
break;
case 'Appwrite\Utopia\Database\Validator\CustomId':
if ($route->getLabel('sdk.methodType', '') === 'upload') {
$node['schema']['x-upload-id'] = true;
}
$node['schema']['type'] = $validator->getType();
$node['schema']['x-example'] = '<' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . '>';
$node['schema']['x-example'] = '[' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . ']';
break;
case 'Utopia\Database\Validator\DatetimeValidator':
$node['schema']['type'] = $validator->getType();
@@ -297,7 +297,7 @@ class Swagger2 extends Format
switch ((!empty($validator)) ? \get_class($validator) : '') {
case 'Utopia\Validator\Text':
$node['type'] = $validator->getType();
$node['x-example'] = '<' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . '>';
$node['x-example'] = '[' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . ']';
break;
case 'Utopia\Validator\Boolean':
$node['type'] = $validator->getType();
@@ -308,11 +308,11 @@ class Swagger2 extends Format
$node['x-upload-id'] = true;
}
$node['type'] = $validator->getType();
$node['x-example'] = '<' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . '>';
$node['x-example'] = '[' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . ']';
break;
case 'Utopia\Database\Validator\UID':
$node['type'] = $validator->getType();
$node['x-example'] = '<' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . '>';
$node['x-example'] = '[' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . ']';
break;
case 'Utopia\Database\Validator\DatetimeValidator':
$node['type'] = $validator->getType();