Skip to content

Add Email Templates migration#190

Open
premtsd-code wants to merge 8 commits into
add-custom-domains-migrationfrom
add-email-templates-migration
Open

Add Email Templates migration#190
premtsd-code wants to merge 8 commits into
add-custom-domains-migrationfrom
add-email-templates-migration

Conversation

@premtsd-code
Copy link
Copy Markdown
Contributor

Summary

  • Adds TYPE_PROJECT_EMAIL_TEMPLATE to GROUP_PROJECTS_RESOURCES for migrating the project's per-locale email template overrides.
  • Source (Sources/Appwrite) reads templates via Project::listEmailTemplates (offset-paginated; not cursor) and emits one EmailTemplate resource per (type, locale).
  • Destination (Destinations/Appwrite) replays them via Project::updateEmailTemplate for each entry.
  • No new group: per the abnegate review on feat(migration): add project-level resource migrations #186, project's own email copy is just another per-project singleton — it belongs in GROUP_PROJECTS alongside PROJECT_VARIABLE / PROJECT_PROTOCOLS / PROJECT_LABELS / PROJECT_SERVICES.

Test plan

  • CI lints + tests green
  • E2E testAppwriteMigrationEmailTemplates (in appwrite/appwrite) passes

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 28, 2026

Greptile Summary

This PR adds email template migration support (TYPE_PROJECT_EMAIL_TEMPLATE) to the Appwrite-to-Appwrite migration path, covering per-locale overrides for all template types in a project.

  • Source (Sources/Appwrite.php): offset-paginates listEmailTemplates (cursor pagination is unavailable for this endpoint) and emits one EmailTemplate resource per (templateId, locale) pair; the report count uses total: true, which is confirmed valid by the SDK docs.
  • Destination (Destinations/Appwrite.php): writes templates directly to the projects document via dbForPlatform rather than the SDK's updateEmailTemplate (which requires custom SMTP to be enabled), using the same read-modify-write + cache-purge pattern already established by createServices and createSMTP.
  • Resource (Resources/Templates/EmailTemplate.php): new class with typed getters, fromArray with null-coalescence guards, and jsonSerialize mapping bodymessage consistently with the SDK wire format.

Confidence Score: 5/5

Safe to merge — the new code follows established patterns throughout the codebase and no correctness issues were found.

The destination write uses the same read-modify-write + cache-purge pattern as createServices and createSMTP, proven correct for sequential per-resource processing. The total: true named argument on listEmailTemplates is confirmed valid by the Appwrite PHP SDK docs. Null-coalescence guards in fromArray are consistent with the model's guaranteed-empty-string wire format.

No files require special attention.

Important Files Changed

Filename Overview
src/Migration/Resources/Templates/EmailTemplate.php New resource class modelling one (templateId, locale) pair; follows the existing Resource contract correctly with fromArray, jsonSerialize, and typed getters.
src/Migration/Sources/Appwrite.php Adds exportEmailTemplates with offset pagination and report count via listEmailTemplates(total: true); pattern matches other GROUP_PROJECTS exporters and the total: true named arg is confirmed valid by the SDK docs.
src/Migration/Destinations/Appwrite.php Adds createEmailTemplate using the established read-modify-write + cache-purge pattern (identical to createServices and createSMTP); direct DB write correctly bypasses the SMTP-gated SDK endpoint.
src/Migration/Resource.php Adds TYPE_PROJECT_EMAIL_TEMPLATE constant and registers it in GROUP_PROJECTS_RESOURCES; consistent with other project-level resource types.
src/Migration/Transfer.php Adds the new type to both GROUP_PROJECTS_RESOURCES and the global resource list; correctly placed alongside other per-project singletons.
tests/Migration/Unit/Adapters/MockDestination.php Registers TYPE_PROJECT_EMAIL_TEMPLATE in the mock's supported-resources list; minimal, correct change.
tests/Migration/Unit/Adapters/MockSource.php Registers TYPE_PROJECT_EMAIL_TEMPLATE in the mock's supported-resources list; minimal, correct change.

Reviews (4): Last reviewed commit: "Register TYPE_PROJECT_EMAIL_TEMPLATE in ..." | Re-trigger Greptile

Comment thread src/Migration/Sources/Appwrite.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.

1 participant