Skip to content

feat(messaging): migrate messaging service to the module structure - #13564

Merged
ArnabChatterjee20k merged 8 commits into
mainfrom
feat-messaging-module
Sep 9, 2026
Merged

ArnabChatterjee20k merged 8 commits into
mainfrom
feat-messaging-module

Conversation

@ArnabChatterjee20k

@ArnabChatterjee20k ArnabChatterjee20k commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

What

Migrates the entire Messaging service from the legacy monolithic controller (app/controllers/api/messaging.php, ~4,556 lines) into the new module structure under src/Appwrite/Platform/Modules/Messaging/, following the same conventions as the Functions and Databases modules.

All 46 routes are ported as Action classes. No public API change — paths, SDK method names/namespaces/groups, params, validators, labels, events, audits and response models are preserved verbatim.

Structure

Modules/Messaging/
├── Module.php
├── Services/Http.php                 # registers all 46 actions
└── Http/
    ├── Providers/                    # list, get, delete +
    │   ├── Mailgun|Sendgrid|Ses|Resend|Smtp/      Create, Update   (email)
    │   ├── Msg91|Telesign|Textmagic|Twilio|Vonage/ Create, Update   (sms)
    │   └── Fcm|Apns/                               Create, Update   (push)
    ├── Topics/                       # Create, XList, Get, Update, Delete
    │   └── Subscribers/              # Create, XList, Get, Delete
    └── Messages/                     # XList, Get, Delete +
        ├── Email|Sms|Push/           # Create, Update
        └── Targets/                  # XList

Type-specific creates/updates (providers by vendor, messages by channel) follow the existing Databases/Columns/{Type} nesting pattern. Subscribers nest under Topics/, targets under Messages/, since they are child resources of those paths.

How it was done

Committed in small, reviewable slices — one per resource group — so history reads as a progression rather than one 46-file drop:

  1. Scaffold module + Providers reference slice (Mailgun + list/get/delete)
  2. Push providers (FCM, APNS)
  3. Email providers (Sendgrid, SES, Resend, SMTP)
  4. SMS providers (Msg91, Telesign, Textmagic, Twilio, Vonage)
  5. Topics + Subscribers
  6. Messages + Targets
  7. Switchover — register Messaging\Module, flip services.php to 'controller' => '', delete the old controller

The module is only wired into the platform in the final commit, so no HTTP path is ever registered twice during the migration.

Notes on fidelity

  • Dual SDK Method arrays preserved for FCM/APNS/SMTP/SMS, i.e. the deprecated lowercase name (createFcmProvider, createSms, createSmtpProvider) alongside the canonical uppercase one (createFCMProvider, createSMS, createSMTPProvider), including the Deprecated blocks and public: false. This keeps generated SDKs and specs byte-for-byte compatible.
  • normalizeJsonObject was a global function defined in the deleted controller. Per the reuse guidance (no globals, no Helper classes), it is reintroduced as a small private method on the two Push message actions and the two FCM provider actions that use it — a little duplication over a shared global hook.
  • getName() returns each route's existing SDK method name (unique per action); the public sdk label keeps the full (possibly dual) Method set.

Verification

Run locally and clean:

  • composer lint and composer analyze (PHPStan level 4) over the whole module and Appwrite.php
  • composer refactor:check (Rector)
  • 46 registered actions = 46 action files; all 39 unique HTTP paths match the old controller exactly; no duplicate getName()s; no remaining references to the deleted controller or its global

Requires the container / CI (Swoole not available in a bare local CLI, so app/cli.php specs and the boot path can't run here):

  • php app/cli.php specs --version=latest --git=no produces an unchanged spec diff
  • docker compose exec appwrite test tests/e2e/Services/Messaging

Risk

Pure refactor. The main risk surface is (a) any route whose SDK metadata drifted during the port and (b) container boot / route registration — both covered by the spec-diff and e2e gates above, which should be green before merge.

🤖 Generated with Claude Code

Add Module.php, Services/Http.php, and the Providers group reference
(Mailgun create/update, list, get, delete) as Action classes under the
new module structure. Not yet registered in Appwrite.php; the old
controller stays authoritative until the migration completes.
Add create/update actions for the FCM and APNS push providers, preserving
their dual SDK Method arrays (deprecated lowercase + canonical uppercase
names) verbatim, and register them in the module Http service.
Add create/update actions for the Sendgrid, SES, Resend and SMTP email
providers and register them; SMTP keeps its dual SDK Method array
(deprecated + canonical SMTP-cased names) verbatim.
Add create/update actions for the Msg91, Telesign, Textmagic, Twilio and
Vonage SMS providers and register them in the module Http service.
Add CRUD actions for topics and the nested topic subscribers
(create/list/get/delete) and register them in the module Http service.
Add email/sms/push message create+update, list, get, delete, and the
nested message targets list, and register them. Push create/update carry
their own private normalizeJsonObject (no shared global); FCM providers
get the same private helper so they no longer depend on the controller's
global that this migration removes.
Register Messaging\Module in the platform, flip the messaging service to
'controller' => '' so it is served by modules, and remove the legacy
app/controllers/api/messaging.php now that all 46 routes are ported.
@ArnabChatterjee20k ArnabChatterjee20k changed the title Feat messaging module feat(messaging): migrate messaging service to the module structure Sep 9, 2026
@greptile-apps

greptile-apps Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with no outstanding correctness, security, or repository-rule violations identified.

Summary

  • Registers the new Messaging module and its HTTP service.
  • Splits provider, topic, subscriber, message, and target endpoints into dedicated action classes.
  • Disables and removes the legacy Messaging controller.
  • Preserves the existing provider-specific and deprecated SDK method metadata.

@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat-messaging-module (after).

Metric Before After Change
🚀 Requests/sec 257.43 241.1 🔴 -6.3%
⏱️ Latency P50 67.71 ms 72.27 ms 🔴 +6.7%
⏱️ Latency P95 159.5 ms 171.1 ms 🔴 +7.3%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 72.27 171.1 14,934 241.1 +11.59
Account 139.96 249.62 786 13.06 +5.25
TablesDB 70.24 130.4 8,122 132.59 +12.48
Storage 65.16 153.6 3,930 66.44 +12.34
Functions 103.74 206.18 2,096 36.14 +14.44

Top API waits (after)

API request Max wait (ms)
account.name.update 425.36
functions.variables.update 374
storage.files.get 369.55
functions.variables.delete 350.06
functions.variables.create 342.75

@ArnabChatterjee20k
ArnabChatterjee20k merged commit 04f2c0f into main Sep 9, 2026
46 checks passed
@ChiragAgg5k ChiragAgg5k mentioned this pull request Sep 10, 2026
2 of 4 tasks
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