diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index 7af35c2dda..ee263d105b 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -291,10 +291,10 @@ class Appwrite extends Destination // Integrations Resource::TYPE_PLATFORM, Resource::TYPE_API_KEY, + Resource::TYPE_WEBHOOK, // Settings Resource::TYPE_PROJECT_VARIABLE, - Resource::TYPE_WEBHOOK, Resource::TYPE_PROTOCOLS, Resource::TYPE_LABELS, Resource::TYPE_SERVICES, @@ -3110,6 +3110,10 @@ class Appwrite extends Destination /** @var ApiKey $resource */ $this->createApiKey($resource); break; + case Resource::TYPE_WEBHOOK: + /** @var Webhook $resource */ + $this->createWebhook($resource); + break; } if ($resource->getStatus() !== Resource::STATUS_SKIPPED) { @@ -3126,10 +3130,6 @@ class Appwrite extends Destination /** @var ProjectVariable $resource */ $this->createProjectVariable($resource); break; - case Resource::TYPE_WEBHOOK: - /** @var Webhook $resource */ - $this->createWebhook($resource); - break; case Resource::TYPE_PROTOCOLS: /** @var Protocols $resource */ $this->createProtocols($resource); diff --git a/src/Migration/Sources/Appwrite.php b/src/Migration/Sources/Appwrite.php index 1b9c601ee5..d796a9fa74 100644 --- a/src/Migration/Sources/Appwrite.php +++ b/src/Migration/Sources/Appwrite.php @@ -226,13 +226,13 @@ class Appwrite extends Source // Integrations Resource::TYPE_PLATFORM, Resource::TYPE_API_KEY, + Resource::TYPE_WEBHOOK, // Backups Resource::TYPE_BACKUP_POLICY, // Settings Resource::TYPE_PROJECT_VARIABLE, - Resource::TYPE_WEBHOOK, Resource::TYPE_PROTOCOLS, Resource::TYPE_LABELS, Resource::TYPE_SERVICES, @@ -1582,19 +1582,6 @@ class Appwrite extends Source } } - if (\in_array(Resource::TYPE_WEBHOOK, $resources)) { - $webhookQueries = $this->buildQueries( - resourceType: Resource::TYPE_WEBHOOK, - resourceIds: $resourceIds, - limit: 1 - ); - try { - $report[Resource::TYPE_WEBHOOK] = $this->webhooks->list($webhookQueries)->total; - } catch (\Throwable) { - $report[Resource::TYPE_WEBHOOK] = 0; - } - } - if (\in_array(Resource::TYPE_PROTOCOLS, $resources)) { // Singleton — there is exactly one protocols config per project. $report[Resource::TYPE_PROTOCOLS] = 1; @@ -1631,20 +1618,6 @@ class Appwrite extends Source } } - if (\in_array(Resource::TYPE_WEBHOOK, $resources)) { - try { - $this->exportWebhooks($batchSize); - } catch (\Throwable $e) { - $this->addError(new Exception( - Resource::TYPE_WEBHOOK, - Transfer::GROUP_SETTINGS, - message: $e->getMessage(), - code: (int) $e->getCode() ?: Exception::CODE_INTERNAL, - previous: $e - )); - } - } - try { if (\in_array(Resource::TYPE_PROTOCOLS, $resources)) { $this->exportProtocols(); @@ -2661,6 +2634,19 @@ class Appwrite extends Source $report[Resource::TYPE_API_KEY] = 0; } } + + if (\in_array(Resource::TYPE_WEBHOOK, $resources)) { + $webhookQueries = $this->buildQueries( + resourceType: Resource::TYPE_WEBHOOK, + resourceIds: $resourceIds, + limit: 1 + ); + try { + $report[Resource::TYPE_WEBHOOK] = $this->webhooks->list($webhookQueries)->total; + } catch (\Throwable) { + $report[Resource::TYPE_WEBHOOK] = 0; + } + } } /** @@ -2720,6 +2706,20 @@ class Appwrite extends Source )); } } + + if (\in_array(Resource::TYPE_WEBHOOK, $resources)) { + try { + $this->exportWebhooks($batchSize); + } catch (\Throwable $e) { + $this->addError(new Exception( + Resource::TYPE_WEBHOOK, + Transfer::GROUP_INTEGRATIONS, + message: $e->getMessage(), + code: $e->getCode(), + previous: $e + )); + } + } } /** diff --git a/src/Migration/Transfer.php b/src/Migration/Transfer.php index e14c57d780..2856c86dc3 100644 --- a/src/Migration/Transfer.php +++ b/src/Migration/Transfer.php @@ -67,6 +67,7 @@ class Transfer public const GROUP_INTEGRATIONS_RESOURCES = [ Resource::TYPE_PLATFORM, Resource::TYPE_API_KEY, + Resource::TYPE_WEBHOOK, ]; public const GROUP_DOCUMENTSDB_RESOURCES = [ Resource::TYPE_DATABASE_DOCUMENTSDB, @@ -98,7 +99,6 @@ class Transfer public const GROUP_SETTINGS_RESOURCES = [ Resource::TYPE_PROJECT_VARIABLE, - Resource::TYPE_WEBHOOK, Resource::TYPE_PROTOCOLS, Resource::TYPE_LABELS, Resource::TYPE_SERVICES, @@ -143,10 +143,10 @@ class Transfer // Integrations Resource::TYPE_PLATFORM, Resource::TYPE_API_KEY, + Resource::TYPE_WEBHOOK, // Settings Resource::TYPE_PROJECT_VARIABLE, - Resource::TYPE_WEBHOOK, Resource::TYPE_PROTOCOLS, Resource::TYPE_LABELS, Resource::TYPE_SERVICES,