Skip to content

Add webhook migration support#185

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

Add webhook migration support#185
premtsd-code wants to merge 7 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 adds webhook as a migratable resource, covering export from the Appwrite SDK's Webhooks::list() and direct import into dbForPlatform via createWebhook(). The group routing, dispatch, and field mapping are all correct in the final state.

  • Source (Sources/Appwrite.php): exportWebhooks() uses cursor pagination via the dedicated Webhooks service; tlssecurity and authUsername/authPasswordhttpUser/httpPass mappings are intentional.
  • Destination (Destinations/Appwrite.php): createWebhook() writes to dbForPlatform, regenerates signatureKey with bin2hex(random_bytes(64)) matching upstream behavior, and purges the project cache on success.
  • Resource class (Resources/Settings/Webhook.php): getGroup() correctly returns Transfer::GROUP_INTEGRATIONS, so the dispatch router in importIntegrationsResource() reaches createWebhook() as expected.

Confidence Score: 5/5

Safe to merge; the webhook resource is correctly wired end-to-end from export through import.

The group routing, dispatch switch, and DB write all connect correctly. The one comment-placement nit in Resource.php has no runtime effect. Previously flagged concerns have been addressed or are pre-existing patterns shared with other resource types.

No files require special attention.

Important Files Changed

Filename Overview
src/Migration/Destinations/Appwrite.php Adds createWebhook() to the platform DB, dispatched via importIntegrationsResource; dedup uses name-only match (pre-flagged); fresh signatureKey generation is correct.
src/Migration/Sources/Appwrite.php Adds exportWebhooks() using the Webhooks SDK service with cursor pagination; field mapping (tls→security, authUsername→httpUser) is correct.
src/Migration/Resources/Settings/Webhook.php New Webhook resource class with correct getGroup() returning GROUP_INTEGRATIONS; all getters implemented cleanly.
src/Migration/Resource.php TYPE_WEBHOOK constant added but placed under the // Settings comment section instead of // Integrations, creating a misleading classification.
src/Migration/Transfer.php TYPE_WEBHOOK correctly added to GROUP_INTEGRATIONS_RESOURCES and ALL_PUBLIC_RESOURCES under the // Integrations section.
tests/Migration/Unit/Adapters/MockDestination.php TYPE_WEBHOOK and TYPE_PROJECT_VARIABLE added to supported resources list.
tests/Migration/Unit/Adapters/MockSource.php TYPE_WEBHOOK and TYPE_PROJECT_VARIABLE added to supported resources list.

Reviews (8): Last reviewed commit: "Register TYPE_PROJECT_VARIABLE and TYPE_..." | 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