Skip to content

fix: webhook paused email template broken rendering#11828

Open
pmartin-dev wants to merge 1 commit intoappwrite:1.9.xfrom
pmartin-dev:fix-8931-webhook-paused-email-template
Open

fix: webhook paused email template broken rendering#11828
pmartin-dev wants to merge 1 commit intoappwrite:1.9.xfrom
pmartin-dev:fix-8931-webhook-paused-email-template

Conversation

@pmartin-dev
Copy link
Copy Markdown

What does this PR do?

Fixes #8931 — The webhook paused email notification was broken and rendered with
duplicated/malformed content.

Root causes:

  • {{subject}} and {{message}} were used instead of {{heading}} and
    {{body}}, so the content never rendered in the base styled template
  • Styling variables (logo, social links, terms/privacy) were set on the inner
    template instead of the base template
  • {{user}} was never resolved because the body was rendered before the user loop
  • {{host}} was never set, breaking the "Webhook settings" link

Fix: Migrated to setBodyTemplate() pattern, consistent with
Certificates.php and Migrations.php workers (as the TODO comment on the removed
line suggested).

Test Plan

  1. Create a webhook pointing to a non-existent URL
  2. Assign events (e.g. buckets.*) and trigger them until retry threshold is
    exceeded
  3. Verify the paused email renders correctly: heading, user name, webhook details,
    social links, and a working "Webhook settings" link

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 8, 2026

Greptile Summary

This PR fixes broken rendering of the webhook-paused email notification by migrating sendEmailAlert in Webhooks.php to the setBodyTemplate pattern already used by Certificates.php and Migrations.php. The old code pre-rendered the outer email-base-styled.tpl in the wrong place (passing {{subject}}/{{message}} instead of {{heading}}/{{body}}), resolved {{user}} before iterating users, and left {{host}} unset. The new approach delegates outer-template rendering and {{host}} injection to the Mails worker, which handles both automatically.

Confidence Score: 5/5

Safe to merge — the fix is a straightforward migration to an established pattern with no regressions introduced.

The change is minimal and consistent with how Certificates.php and Migrations.php handle the same email flow. The Mails worker automatically injects {{host}}, {{heading}}, and {{year}}, so all previously broken placeholders are now correctly resolved. No logic is altered beyond the template rendering path.

No files require special attention.

Vulnerabilities

No security concerns identified.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Workers/Webhooks.php Refactors sendEmailAlert to use setBodyTemplate + setBody pattern; correctly resolves {{user}} per-iteration and delegates {{host}}/{{heading}} injection to the Mails worker.

Reviews (1): Last reviewed commit: "fix: webhook paused email template broke..." | Re-trigger Greptile

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.

🐛 Bug Report: Webhook paused emails template is broken

1 participant