Merge branch '1.8.x' into release-array-param-enums

This commit is contained in:
Chirag Aggarwal 2026-02-02 18:35:20 +05:30
commit 19bfda541f
2 changed files with 40 additions and 30 deletions

View file

@ -129,6 +129,11 @@ class Messaging extends Action
$userIds = $message->getAttribute('users', []);
$providerType = $message->getAttribute('providerType');
Console::log(json_encode([
'project' => $project->getId(),
'type' => $providerType,
]));
/**
* @var array<Document> $allTargets
*/
@ -400,7 +405,10 @@ class Messaging extends Action
throw new \Exception('Project not set in payload');
}
Console::log('Processing project: ' . $project->getId());
Console::log(json_encode([
'project' => $project->getId(),
'type' => 'internal-sms'
]));
$denyList = System::getEnv('_APP_SMS_PROJECTS_DENY_LIST', '');
$denyList = explode(',', $denyList);
if (\in_array($project->getId(), $denyList)) {

View file

@ -26,7 +26,6 @@ use Utopia\Migration\Destinations\Appwrite as DestinationAppwrite;
use Utopia\Migration\Destinations\CSV as DestinationCSV;
use Utopia\Migration\Exception as MigrationException;
use Utopia\Migration\Source;
use Utopia\Migration\Sources\Appwrite;
use Utopia\Migration\Sources\Appwrite as SourceAppwrite;
use Utopia\Migration\Sources\CSV;
use Utopia\Migration\Sources\Firebase;
@ -160,19 +159,19 @@ class Migrations extends Action
/**
* @throws Exception
*/
protected function processSource(Document $migration, array $platform): Source
protected function processSource(Document $migration): Source
{
$source = $migration->getAttribute('source');
$destination = $migration->getAttribute('destination');
$resourceId = $migration->getAttribute('resourceId');
$credentials = $migration->getAttribute('credentials');
$migrationOptions = $migration->getAttribute('options');
$dataSource = Appwrite::SOURCE_API;
$dataSource = SourceAppwrite::SOURCE_API;
$database = null;
$queries = [];
if ($source === Appwrite::getName() && $destination === DestinationCSV::getName()) {
$dataSource = Appwrite::SOURCE_DATABASE;
if ($source === SourceAppwrite::getName() && $destination === DestinationCSV::getName()) {
$dataSource = SourceAppwrite::SOURCE_DATABASE;
$database = $this->dbForProject;
$queries = Query::parseQueries($migrationOptions['queries']);
}
@ -225,18 +224,17 @@ class Migrations extends Action
/**
* @throws Exception
*/
protected function processDestination(Document $migration, string $apiKey, array $platform): Destination
protected function processDestination(Document $migration): Destination
{
$destination = $migration->getAttribute('destination');
$options = $migration->getAttribute('options', []);
$protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https';
$credentials = $migration->getAttribute('credentials');
return match ($destination) {
DestinationAppwrite::getName() => new DestinationAppwrite(
$this->project->getId(),
$protocol . '://' . $platform['apiHostname'] . '/v1',
$apiKey,
$credentials['destinationEndpoint'],
$credentials['destinationApiKey'],
$this->dbForProject,
Config::getParam('collections', [])['databases']['collections'],
),
@ -335,31 +333,35 @@ class Migrations extends Action
$transfer = $source = $destination = null;
$protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https';
$endpoint = $protocol . '://' . $platform['apiHostname'] . '/v1';
try {
if (
$migration->getAttribute('source') === SourceAppwrite::getName() &&
empty($migration->getAttribute('credentials', []))
) {
$credentials = $migration->getAttribute('credentials', []);
$credentials = $migration->getAttribute('credentials', []);
if ($migration->getAttribute('source') === SourceAppwrite::getName()) {
$credentials['projectId'] = $credentials['projectId'] ?? $project->getId();
$credentials['apiKey'] = $credentials['apiKey'] ?? $tempAPIKey;
/**
* endpoint set
*/
if (empty($credentials['endpoint'])) {
$protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https';
$credentials['endpoint'] = $protocol . '://' . $platform['apiHostname'] . '/v1';
}
$migration->setAttribute('credentials', $credentials);
$credentials['endpoint'] = $credentials['endpoint'] ?? $endpoint;
}
if ($migration->getAttribute('destination') === DestinationAppwrite::getName()) {
$credentials['destinationApiKey'] = $tempAPIKey;
$credentials['destinationEndpoint'] = $endpoint;
}
if (($credentials['endpoint'] ?? '') === 'http://localhost/v1') {
$credentials['endpoint'] = $endpoint;
}
$migration->setAttribute('credentials', $credentials);
$migration->setAttribute('stage', 'processing');
$migration->setAttribute('status', 'processing');
$this->updateMigrationDocument($migration, $project, $queueForRealtime);
$source = $this->processSource($migration, $platform);
$destination = $this->processDestination($migration, $tempAPIKey, $platform);
$source = $this->processSource($migration);
$destination = $this->processDestination($migration);
$transfer = new Transfer(
$source,
@ -479,6 +481,7 @@ class Migrations extends Action
array $platform,
Authorization $authorization,
): void {
$credentials = $migration->getAttribute('credentials', []);
$options = $migration->getAttribute('options', []);
$bucketId = 'default'; // Always use platform default bucket
$filename = $options['filename'] ?? 'export_' . \time();
@ -574,9 +577,8 @@ class Migrations extends Action
]);
// Generate download URL with JWT
$endpoint = System::getEnv('_APP_DOMAIN', '');
$protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled' ? 'https' : 'http';
$downloadUrl = "{$protocol}://{$endpoint}/v1/storage/buckets/{$bucketId}/files/{$fileId}/push?project={$project->getId()}&jwt={$jwt}";
$downloadUrl = "{$credentials['endpoint']}/storage/buckets/{$bucketId}/files/{$fileId}/push?project={$project->getId()}&jwt={$jwt}";
$options['downloadUrl'] = $downloadUrl;
$migration->setAttribute('options', $options);
$this->updateMigrationDocument($migration, $project, $queueForRealtime);