Merge branch '1.5.x' into prepare-1.5.7
This commit is contained in:
commit
0fcb76570d
8 changed files with 71 additions and 38 deletions
|
@ -11,9 +11,7 @@ $httpsPort = $this->getParam('httpsPort', '');
|
||||||
$version = $this->getParam('version', '');
|
$version = $this->getParam('version', '');
|
||||||
$organization = $this->getParam('organization', '');
|
$organization = $this->getParam('organization', '');
|
||||||
$image = $this->getParam('image', '');
|
$image = $this->getParam('image', '');
|
||||||
?>version: '3'
|
?>services:
|
||||||
|
|
||||||
services:
|
|
||||||
traefik:
|
traefik:
|
||||||
image: traefik:2.11
|
image: traefik:2.11
|
||||||
container_name: appwrite-traefik
|
container_name: appwrite-traefik
|
||||||
|
@ -523,6 +521,8 @@ services:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- appwrite
|
- appwrite
|
||||||
|
volumes:
|
||||||
|
- appwrite-uploads:/storage/uploads:rw
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
environment:
|
environment:
|
||||||
|
@ -542,6 +542,27 @@ services:
|
||||||
- _APP_LOGGING_CONFIG
|
- _APP_LOGGING_CONFIG
|
||||||
- _APP_SMS_FROM
|
- _APP_SMS_FROM
|
||||||
- _APP_SMS_PROVIDER
|
- _APP_SMS_PROVIDER
|
||||||
|
- _APP_STORAGE_DEVICE
|
||||||
|
- _APP_STORAGE_S3_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_S3_SECRET
|
||||||
|
- _APP_STORAGE_S3_REGION
|
||||||
|
- _APP_STORAGE_S3_BUCKET
|
||||||
|
- _APP_STORAGE_DO_SPACES_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_DO_SPACES_SECRET
|
||||||
|
- _APP_STORAGE_DO_SPACES_REGION
|
||||||
|
- _APP_STORAGE_DO_SPACES_BUCKET
|
||||||
|
- _APP_STORAGE_BACKBLAZE_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_BACKBLAZE_SECRET
|
||||||
|
- _APP_STORAGE_BACKBLAZE_REGION
|
||||||
|
- _APP_STORAGE_BACKBLAZE_BUCKET
|
||||||
|
- _APP_STORAGE_LINODE_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_LINODE_SECRET
|
||||||
|
- _APP_STORAGE_LINODE_REGION
|
||||||
|
- _APP_STORAGE_LINODE_BUCKET
|
||||||
|
- _APP_STORAGE_WASABI_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_WASABI_SECRET
|
||||||
|
- _APP_STORAGE_WASABI_REGION
|
||||||
|
- _APP_STORAGE_WASABI_BUCKET
|
||||||
|
|
||||||
appwrite-worker-migrations:
|
appwrite-worker-migrations:
|
||||||
image: <?php echo $organization; ?>/<?php echo $image; ?>:<?php echo $version."\n"; ?>
|
image: <?php echo $organization; ?>/<?php echo $image; ?>:<?php echo $version."\n"; ?>
|
||||||
|
|
|
@ -34,7 +34,6 @@ use Utopia\Queue\Connection;
|
||||||
use Utopia\Queue\Message;
|
use Utopia\Queue\Message;
|
||||||
use Utopia\Queue\Server;
|
use Utopia\Queue\Server;
|
||||||
use Utopia\Registry\Registry;
|
use Utopia\Registry\Registry;
|
||||||
use Utopia\Storage\Device\Local;
|
|
||||||
use Utopia\System\System;
|
use Utopia\System\System;
|
||||||
|
|
||||||
Authorization::disable();
|
Authorization::disable();
|
||||||
|
@ -273,9 +272,6 @@ Server::setResource('deviceForCache', function (Document $project) {
|
||||||
return getDevice(APP_STORAGE_CACHE . '/app-' . $project->getId());
|
return getDevice(APP_STORAGE_CACHE . '/app-' . $project->getId());
|
||||||
}, ['project']);
|
}, ['project']);
|
||||||
|
|
||||||
Server::setResource('deviceForLocalFiles', function (Document $project) {
|
|
||||||
return new Local(APP_STORAGE_UPLOADS . '/app-' . $project->getId());
|
|
||||||
}, ['project']);
|
|
||||||
|
|
||||||
$pools = $register->get('pools');
|
$pools = $register->get('pools');
|
||||||
$platform = new Appwrite();
|
$platform = new Appwrite();
|
||||||
|
|
2
composer.lock
generated
2
composer.lock
generated
|
@ -5613,5 +5613,5 @@
|
||||||
"platform-overrides": {
|
"platform-overrides": {
|
||||||
"php": "8.3"
|
"php": "8.3"
|
||||||
},
|
},
|
||||||
"plugin-api-version": "2.6.0"
|
"plugin-api-version": "2.2.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -570,6 +570,7 @@ services:
|
||||||
networks:
|
networks:
|
||||||
- appwrite
|
- appwrite
|
||||||
volumes:
|
volumes:
|
||||||
|
- appwrite-uploads:/storage/uploads:rw
|
||||||
- ./app:/usr/src/code/app
|
- ./app:/usr/src/code/app
|
||||||
- ./src:/usr/src/code/src
|
- ./src:/usr/src/code/src
|
||||||
depends_on:
|
depends_on:
|
||||||
|
@ -592,6 +593,27 @@ services:
|
||||||
- _APP_SMS_FROM
|
- _APP_SMS_FROM
|
||||||
- _APP_SMS_PROVIDER
|
- _APP_SMS_PROVIDER
|
||||||
- _APP_SMS_PROJECTS_DENY_LIST
|
- _APP_SMS_PROJECTS_DENY_LIST
|
||||||
|
- _APP_STORAGE_DEVICE
|
||||||
|
- _APP_STORAGE_S3_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_S3_SECRET
|
||||||
|
- _APP_STORAGE_S3_REGION
|
||||||
|
- _APP_STORAGE_S3_BUCKET
|
||||||
|
- _APP_STORAGE_DO_SPACES_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_DO_SPACES_SECRET
|
||||||
|
- _APP_STORAGE_DO_SPACES_REGION
|
||||||
|
- _APP_STORAGE_DO_SPACES_BUCKET
|
||||||
|
- _APP_STORAGE_BACKBLAZE_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_BACKBLAZE_SECRET
|
||||||
|
- _APP_STORAGE_BACKBLAZE_REGION
|
||||||
|
- _APP_STORAGE_BACKBLAZE_BUCKET
|
||||||
|
- _APP_STORAGE_LINODE_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_LINODE_SECRET
|
||||||
|
- _APP_STORAGE_LINODE_REGION
|
||||||
|
- _APP_STORAGE_LINODE_BUCKET
|
||||||
|
- _APP_STORAGE_WASABI_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_WASABI_SECRET
|
||||||
|
- _APP_STORAGE_WASABI_REGION
|
||||||
|
- _APP_STORAGE_WASABI_BUCKET
|
||||||
|
|
||||||
appwrite-worker-migrations:
|
appwrite-worker-migrations:
|
||||||
entrypoint: worker-migrations
|
entrypoint: worker-migrations
|
||||||
|
|
|
@ -27,14 +27,6 @@ class Compose
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getVersion(): string
|
|
||||||
{
|
|
||||||
return (isset($this->compose['version'])) ? $this->compose['version'] : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Service[]
|
* @return Service[]
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -35,6 +35,7 @@ use Utopia\Messaging\Messages\SMS;
|
||||||
use Utopia\Platform\Action;
|
use Utopia\Platform\Action;
|
||||||
use Utopia\Queue\Message;
|
use Utopia\Queue\Message;
|
||||||
use Utopia\Storage\Device;
|
use Utopia\Storage\Device;
|
||||||
|
use Utopia\Storage\Device\Local;
|
||||||
use Utopia\Storage\Storage;
|
use Utopia\Storage\Storage;
|
||||||
use Utopia\System\System;
|
use Utopia\System\System;
|
||||||
|
|
||||||
|
@ -42,6 +43,8 @@ use function Swoole\Coroutine\batch;
|
||||||
|
|
||||||
class Messaging extends Action
|
class Messaging extends Action
|
||||||
{
|
{
|
||||||
|
private ?Local $localDevice = null;
|
||||||
|
|
||||||
public static function getName(): string
|
public static function getName(): string
|
||||||
{
|
{
|
||||||
return 'messaging';
|
return 'messaging';
|
||||||
|
@ -58,9 +61,8 @@ class Messaging extends Action
|
||||||
->inject('log')
|
->inject('log')
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->inject('deviceForFiles')
|
->inject('deviceForFiles')
|
||||||
->inject('deviceForLocalFiles')
|
|
||||||
->inject('queueForUsage')
|
->inject('queueForUsage')
|
||||||
->callback(fn (Message $message, Log $log, Database $dbForProject, Device $deviceForFiles, Device $deviceForLocalFiles, Usage $queueForUsage) => $this->action($message, $log, $dbForProject, $deviceForFiles, $deviceForLocalFiles, $queueForUsage));
|
->callback(fn (Message $message, Log $log, Database $dbForProject, Device $deviceForFiles, Usage $queueForUsage) => $this->action($message, $log, $dbForProject, $deviceForFiles, $queueForUsage));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,7 +70,6 @@ class Messaging extends Action
|
||||||
* @param Log $log
|
* @param Log $log
|
||||||
* @param Database $dbForProject
|
* @param Database $dbForProject
|
||||||
* @param Device $deviceForFiles
|
* @param Device $deviceForFiles
|
||||||
* @param Device $deviceForLocalFiles
|
|
||||||
* @param Usage $queueForUsage
|
* @param Usage $queueForUsage
|
||||||
* @return void
|
* @return void
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
|
@ -78,7 +79,6 @@ class Messaging extends Action
|
||||||
Log $log,
|
Log $log,
|
||||||
Database $dbForProject,
|
Database $dbForProject,
|
||||||
Device $deviceForFiles,
|
Device $deviceForFiles,
|
||||||
Device $deviceForLocalFiles,
|
|
||||||
Usage $queueForUsage
|
Usage $queueForUsage
|
||||||
): void {
|
): void {
|
||||||
Runtime::setHookFlags(SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_TCP);
|
Runtime::setHookFlags(SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_TCP);
|
||||||
|
@ -101,7 +101,7 @@ class Messaging extends Action
|
||||||
case MESSAGE_SEND_TYPE_EXTERNAL:
|
case MESSAGE_SEND_TYPE_EXTERNAL:
|
||||||
$message = $dbForProject->getDocument('messages', $payload['messageId']);
|
$message = $dbForProject->getDocument('messages', $payload['messageId']);
|
||||||
|
|
||||||
$this->sendExternalMessage($dbForProject, $message, $deviceForFiles, $deviceForLocalFiles, );
|
$this->sendExternalMessage($dbForProject, $message, $deviceForFiles, $project);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new \Exception('Unknown message type: ' . $type);
|
throw new \Exception('Unknown message type: ' . $type);
|
||||||
|
@ -112,7 +112,7 @@ class Messaging extends Action
|
||||||
Database $dbForProject,
|
Database $dbForProject,
|
||||||
Document $message,
|
Document $message,
|
||||||
Device $deviceForFiles,
|
Device $deviceForFiles,
|
||||||
Device $deviceForLocalFiles,
|
Document $project,
|
||||||
): void {
|
): void {
|
||||||
$topicIds = $message->getAttribute('topics', []);
|
$topicIds = $message->getAttribute('topics', []);
|
||||||
$targetIds = $message->getAttribute('targets', []);
|
$targetIds = $message->getAttribute('targets', []);
|
||||||
|
@ -218,8 +218,8 @@ class Messaging extends Action
|
||||||
/**
|
/**
|
||||||
* @var array<array> $results
|
* @var array<array> $results
|
||||||
*/
|
*/
|
||||||
$results = batch(\array_map(function ($providerId) use ($identifiers, &$providers, $default, $message, $dbForProject, $deviceForFiles, $deviceForLocalFiles) {
|
$results = batch(\array_map(function ($providerId) use ($identifiers, &$providers, $default, $message, $dbForProject, $deviceForFiles, $project) {
|
||||||
return function () use ($providerId, $identifiers, &$providers, $default, $message, $dbForProject, $deviceForFiles, $deviceForLocalFiles) {
|
return function () use ($providerId, $identifiers, &$providers, $default, $message, $dbForProject, $deviceForFiles, $project) {
|
||||||
if (\array_key_exists($providerId, $providers)) {
|
if (\array_key_exists($providerId, $providers)) {
|
||||||
$provider = $providers[$providerId];
|
$provider = $providers[$providerId];
|
||||||
} else {
|
} else {
|
||||||
|
@ -246,8 +246,8 @@ class Messaging extends Action
|
||||||
$adapter->getMaxMessagesPerRequest()
|
$adapter->getMaxMessagesPerRequest()
|
||||||
);
|
);
|
||||||
|
|
||||||
return batch(\array_map(function ($batch) use ($message, $provider, $adapter, $dbForProject, $deviceForFiles, $deviceForLocalFiles) {
|
return batch(\array_map(function ($batch) use ($message, $provider, $adapter, $dbForProject, $deviceForFiles, $project) {
|
||||||
return function () use ($batch, $message, $provider, $adapter, $dbForProject, $deviceForFiles, $deviceForLocalFiles) {
|
return function () use ($batch, $message, $provider, $adapter, $dbForProject, $deviceForFiles, $project) {
|
||||||
$deliveredTotal = 0;
|
$deliveredTotal = 0;
|
||||||
$deliveryErrors = [];
|
$deliveryErrors = [];
|
||||||
$messageData = clone $message;
|
$messageData = clone $message;
|
||||||
|
@ -256,7 +256,7 @@ class Messaging extends Action
|
||||||
$data = match ($provider->getAttribute('type')) {
|
$data = match ($provider->getAttribute('type')) {
|
||||||
MESSAGE_TYPE_SMS => $this->buildSmsMessage($messageData, $provider),
|
MESSAGE_TYPE_SMS => $this->buildSmsMessage($messageData, $provider),
|
||||||
MESSAGE_TYPE_PUSH => $this->buildPushMessage($messageData),
|
MESSAGE_TYPE_PUSH => $this->buildPushMessage($messageData),
|
||||||
MESSAGE_TYPE_EMAIL => $this->buildEmailMessage($dbForProject, $messageData, $provider, $deviceForFiles, $deviceForLocalFiles),
|
MESSAGE_TYPE_EMAIL => $this->buildEmailMessage($dbForProject, $messageData, $provider, $deviceForFiles, $project),
|
||||||
default => throw new \Exception('Provider with the requested ID is of the incorrect type')
|
default => throw new \Exception('Provider with the requested ID is of the incorrect type')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -354,8 +354,8 @@ class Messaging extends Action
|
||||||
|
|
||||||
$path = $file->getAttribute('path', '');
|
$path = $file->getAttribute('path', '');
|
||||||
|
|
||||||
if ($deviceForLocalFiles->exists($path)) {
|
if ($this->getLocalDevice($project)->exists($path)) {
|
||||||
$deviceForLocalFiles->delete($path);
|
$this->getLocalDevice($project)->delete($path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -524,7 +524,7 @@ class Messaging extends Action
|
||||||
Document $message,
|
Document $message,
|
||||||
Document $provider,
|
Document $provider,
|
||||||
Device $deviceForFiles,
|
Device $deviceForFiles,
|
||||||
Device $deviceForLocalFiles,
|
Document $project,
|
||||||
): Email {
|
): Email {
|
||||||
$fromName = $provider['options']['fromName'] ?? null;
|
$fromName = $provider['options']['fromName'] ?? null;
|
||||||
$fromEmail = $provider['options']['fromEmail'] ?? null;
|
$fromEmail = $provider['options']['fromEmail'] ?? null;
|
||||||
|
@ -586,7 +586,7 @@ class Messaging extends Action
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($deviceForFiles->getType() !== Storage::DEVICE_LOCAL) {
|
if ($deviceForFiles->getType() !== Storage::DEVICE_LOCAL) {
|
||||||
$deviceForFiles->transfer($path, $path, $deviceForLocalFiles);
|
$deviceForFiles->transfer($path, $path, $this->getLocalDevice($project));
|
||||||
}
|
}
|
||||||
|
|
||||||
$attachment = new Attachment(
|
$attachment = new Attachment(
|
||||||
|
@ -658,4 +658,13 @@ class Messaging extends Action
|
||||||
$badge
|
$badge
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getLocalDevice($project): Local
|
||||||
|
{
|
||||||
|
if($this->localDevice === null) {
|
||||||
|
$this->localDevice = new Local(APP_STORAGE_UPLOADS . '/app-' . $project->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->localDevice;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
version: '3'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
traefik:
|
traefik:
|
||||||
image: traefik:2.2
|
image: traefik:2.2
|
||||||
|
|
|
@ -21,11 +21,6 @@ class ComposeTest extends TestCase
|
||||||
$this->object = new Compose($data);
|
$this->object = new Compose($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testVersion(): void
|
|
||||||
{
|
|
||||||
$this->assertEquals('3', $this->object->getVersion());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testServices(): void
|
public function testServices(): void
|
||||||
{
|
{
|
||||||
$this->assertCount(15, $this->object->getServices());
|
$this->assertCount(15, $this->object->getServices());
|
||||||
|
|
Loading…
Reference in a new issue