Add SMTP migration#187
Conversation
Adds a single SMTP settings resource carrying the project's custom SMTP configuration. Source reads via the typed Project model (Project::get()->smtp*); destination writes the smtp attribute on the project document directly, matching the pattern used by the other 5 settings resources. Password is intentionally not migrated — the source API only exposes smtpPassword as an empty string (write-only field). The destination's existing password is preserved via read-then-merge of the smtp map.
Greptile SummaryThis PR introduces SMTP configuration as a new
Confidence Score: 4/5The change is otherwise clean but createSMTP unconditionally copies the source's enabled flag to the destination even when no destination password is present, which will leave a destination with enabled=true, a populated username, but no password — causing every outbound email attempt to fail silently with an auth error. The enabled flag is written without checking whether the destination actually has a stored password. On a fresh destination where the smtp attribute is empty, the merge preserves only the password that doesn't exist, so the resulting document can end up in an inconsistent state where SMTP appears enabled but cannot authenticate. This defect is on the hot path of every migration that uses custom SMTP. src/Migration/Destinations/Appwrite.php — specifically the createSMTP method's unconditional enabled assignment. Important Files Changed
Reviews (2): Last reviewed commit: "chore: fix import ordering (Pint)" | Re-trigger Greptile |
| $project = $this->dbForPlatform->getDocument('projects', $this->projectId); | ||
| $smtp = $project->getAttribute('smtp', []); | ||
|
|
||
| $smtp['enabled'] = $resource->getEnabled(); |
There was a problem hiding this comment.
SMTP enabled flag copied without a destination password
createSMTP sets $smtp['enabled'] = $resource->getEnabled() unconditionally, but it intentionally skips writing $smtp['password']. On a fresh destination where $project->getAttribute('smtp', []) returns [], the resulting document will have enabled = true alongside a populated username but no password key. Any email delivery attempt will fail with an SMTP AUTH error, with no warning to the user.
The safest fix is to suppress the enabled flag when the destination has no stored password: if empty($smtp['password']), force $smtp['enabled'] = false regardless of the source value.
Adds the project SMTP configuration as a new settings resource. Source reads via the typed
Project::get()model; destination writes the project doc'ssmtpmap directly (read-then-merge to preserve destination password — source API never exposes it). Stacks on top of #186.