Skip to content

Add webhook migration support#185

Open
premtsd-code wants to merge 6 commits into
mainfrom
add-webhook-migration
Open

Add webhook migration support#185
premtsd-code wants to merge 6 commits into
mainfrom
add-webhook-migration

Conversation

@premtsd-code
Copy link
Copy Markdown
Contributor

Summary

Stacks on #184. Adds webhook as a migrable resource.

  • Source: Appwrite SDK Webhooks::list() (separate service from Project) with cursor pagination. Reports via reportIntegrations.
  • Destination: direct dbForPlatform->createDocument('webhooks', ...) matching the upstream Webhooks::Create payload exactly.

Notes

  • Resource::TYPE_WEBHOOK = 'webhook', placed in GROUP_INTEGRATIONS_RESOURCES.
  • Carries through name, url, events, security (TLS), httpUser/httpPass (basic auth), and enabled.
  • Signing secret regenerates: the SDK strips signatureKey on list responses (Webhooks/XList.php explicitly removeAttribute('signatureKey')). Destination generates a fresh bin2hex(random_bytes(64)) to match upstream's createWebhook default. Webhook receivers verifying signatures must be updated with the destination's new key.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 14, 2026

Greptile Summary

This PR introduces webhook migration support, adding Webhook as a migratable resource under the GROUP_INTEGRATIONS group. Source-side cursor-paginated export is wired through the existing Webhooks SDK service, and destination-side creation writes directly to dbForPlatform with a freshly-generated signatureKey (since the SDK strips it from list responses).

  • New Webhook resource class (Resources/Settings/Webhook.php) exposes all webhook fields; getGroup() correctly returns GROUP_INTEGRATIONS, routing it to importIntegrationsResource on the destination.
  • Source (Sources/Appwrite.php): exportWebhooks() follows the established cursor-pagination pattern and reportIntegrations counting is added alongside platforms and API keys.
  • Destination (Destinations/Appwrite.php): createWebhook() mirrors the createPlatform/createApiKey pattern — idempotency check on projectInternalId + name, DB insert, cache purge.

Confidence Score: 5/5

The change is self-contained, follows established patterns for Platform and ApiKey migration, and the group/routing wiring is correct. Safe to merge.

The routing, pagination, dedup, and cache-purge logic all mirror existing sibling resources with no divergence. The only finding is a cosmetic comment-placement nit in Resource.php.

No files require special attention beyond the minor comment-section placement in Resource.php.

Important Files Changed

Filename Overview
src/Migration/Resources/Settings/Webhook.php New Webhook resource class; correctly returns GROUP_INTEGRATIONS from getGroup(), implements all required accessor methods, fromArray, and jsonSerialize.
src/Migration/Sources/Appwrite.php Adds exportWebhooks() with cursor pagination and reportIntegrations counting; pattern mirrors existing exportProjectVariables(); exportGroupIntegrations correctly dispatches webhook export.
src/Migration/Destinations/Appwrite.php Adds TYPE_WEBHOOK to supported resources and importIntegrationsResource switch; createWebhook() writes to dbForPlatform with a freshly-generated signatureKey and purges the project cache.
src/Migration/Resource.php TYPE_WEBHOOK constant added under the // Settings comment, but the resource's group is GROUP_INTEGRATIONS — inconsistent placement that could mislead readers.
src/Migration/Transfer.php TYPE_WEBHOOK correctly added to GROUP_INTEGRATIONS_RESOURCES and ALL_PUBLIC_RESOURCES.

Reviews (7): Last reviewed commit: "Webhook resource reports integrations gr..." | Re-trigger Greptile

Comment thread src/Migration/Destinations/Appwrite.php Outdated
@premtsd-code premtsd-code force-pushed the add-project-variable-migration branch from c040472 to 3376bed Compare May 14, 2026 19:00
- Resource::TYPE_WEBHOOK joins project-variable under the Settings group.
- Source uses Appwrite SDK Webhooks::list() (separate service from
  Project) with cursor pagination.
- Destination writes to dbForPlatform.webhooks matching upstream
  createWebhook payload. Signing secret regenerates on the destination
  because the SDK strips it from list responses (same caveat as api keys).
@premtsd-code premtsd-code force-pushed the add-webhook-migration branch from 6bd9699 to 7fca422 Compare May 14, 2026 19:27
…into add-webhook-migration

# Conflicts:
#	src/Migration/Destinations/Appwrite.php
#	src/Migration/Sources/Appwrite.php
Base automatically changed from add-project-variable-migration to main May 28, 2026 06:28
Comment thread src/Migration/Destinations/Appwrite.php Outdated

// Settings
Resource::TYPE_PROJECT_VARIABLE,
Resource::TYPE_WEBHOOK,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's group this with integrations

Comment thread src/Migration/Resources/Settings/Webhook.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants