From 1a052a0add76ed971522a3cf0438fd7a3218b9e1 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 28 Jan 2025 05:14:42 +0000 Subject: [PATCH] fix latest changes --- app/init/app.php | 29 ++++++++++++++++++++++------- app/init/http.php | 4 ++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/app/init/app.php b/app/init/app.php index 8b5d37369f..e12efd8b33 100644 --- a/app/init/app.php +++ b/app/init/app.php @@ -174,6 +174,7 @@ const DELETE_TYPE_TOPIC = 'topic'; const DELETE_TYPE_TARGET = 'target'; const DELETE_TYPE_EXPIRED_TARGETS = 'invalid_targets'; const DELETE_TYPE_SESSION_TARGETS = 'session_targets'; +const DELETE_TYPE_MAINTENANCE = 'maintenance'; // Message types const MESSAGE_SEND_TYPE_INTERNAL = 'internal'; @@ -700,6 +701,7 @@ Database::addFilter( } ); + Database::addFilter( 'messageSearch', function (mixed $value, Document $message) { @@ -712,12 +714,19 @@ Database::addFilter( $data = \json_decode($message->getAttribute('data', []), true); $providerType = $message->getAttribute('providerType', ''); - if ($providerType === MESSAGE_TYPE_EMAIL) { - $searchValues = \array_merge($searchValues, [$data['subject'], MESSAGE_TYPE_EMAIL]); - } elseif ($providerType === MESSAGE_TYPE_SMS) { - $searchValues = \array_merge($searchValues, [$data['content'], MESSAGE_TYPE_SMS]); - } else { - $searchValues = \array_merge($searchValues, [$data['title'], MESSAGE_TYPE_PUSH]); + switch ($providerType) { + case MESSAGE_TYPE_EMAIL: + $searchValues[] = $data['subject']; + $searchValues[] = MESSAGE_TYPE_EMAIL; + break; + case MESSAGE_TYPE_SMS: + $searchValues[] = $data['content']; + $searchValues[] = MESSAGE_TYPE_SMS; + break; + case MESSAGE_TYPE_PUSH: + $searchValues[] = $data['title'] ?? ''; + $searchValues[] = MESSAGE_TYPE_PUSH; + break; } $search = \implode(' ', \array_filter($searchValues)); @@ -741,7 +750,7 @@ Structure::addFormat(APP_DATABASE_ATTRIBUTE_DATETIME, function () { }, Database::VAR_DATETIME); Structure::addFormat(APP_DATABASE_ATTRIBUTE_ENUM, function ($attribute) { - $elements = $attribute['formatOptions']['elements']; + $elements = $attribute['formatOptions']['elements'] ?? []; return new WhiteList($elements, true); }, Database::VAR_STRING); @@ -854,6 +863,12 @@ $register->set('pools', function () { 'multiple' => true, 'schemes' => ['mariadb', 'mysql'], ], + 'logs' => [ + 'type' => 'database', + 'dsns' => System::getEnv('_APP_CONNECTIONS_DB_LOGS', $fallbackForDB), + 'multiple' => false, + 'schemes' => ['mariadb', 'mysql'], + ], 'queue' => [ 'type' => 'queue', 'dsns' => $fallbackForRedis, diff --git a/app/init/http.php b/app/init/http.php index 49c7076be7..853f2b6f16 100644 --- a/app/init/http.php +++ b/app/init/http.php @@ -687,6 +687,10 @@ App::setResource('plan', function (array $plan = []) { return []; }); +App::setResource('smsRates', function () { + return []; +}); + App::setResource('team', function (Document $project, Database $dbForPlatform, App $utopia, Request $request) { $teamInternalId = ''; if ($project->getId() !== 'console') {