fix: Custom email template for Attendees incorrectly routes back to Order (fix by preserving correct cta.url_token on update) π€ #1189
Open
mrjbj wants to merge 1 commit into
Conversation
UpdateEventEmailTemplateAction and UpdateOrganizerEmailTemplateAction hardcoded cta.url_token to 'order.url' on every update, with a TODO comment promising to derive it from template type that was never implemented. Result: any save of an attendee_ticket template overwrote its CTA target so the "View Ticket" button took recipients to the order summary page instead of the ticket page. Move the resolution into UpdateEmailTemplateHandler, which already fetches the existing row, and derive url_token from EmailTemplateService::getDefaultTemplate() based on the row's stored template_type. The actions now pass only the user-supplied label. Adds an artisan command (email-templates:repair-cta-url-token) to rewrite already-corrupted rows in place, plus unit tests covering the attendee_ticket and order_confirmation paths. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes I've made
File: backend/app/Services/Application/Handlers/EmailTemplate/UpdateEmailTemplateHandler.php
Change: New resolveCta() derives url_token from existing template's type via EmailTemplateService::getDefaultTemplate()
ββββββββββββββββββββββββββββββββββββββββ
File: backend/app/Http/Actions/EmailTemplates/UpdateEventEmailTemplateAction.php
Change: Pass only label in CTA; handler is authoritative
ββββββββββββββββββββββββββββββββββββββββ
File: backend/app/Http/Actions/EmailTemplates/UpdateOrganizerEmailTemplateAction.php
Change: Same
ββββββββββββββββββββββββββββββββββββββββ
File: backend/app/Console/Commands/RepairEmailTemplateCtaCommand.php
Change: New email-templates:repair-cta-url-token artisan command (--dry-run supported)
ββββββββββββββββββββββββββββββββββββββββ
File: backend/tests/Unit/Services/Application/Handlers/EmailTemplate/UpdateEmailTemplateHandlerTest.php
Change: 3 new unit tests
Why I've made these changes
When user modifies the custom email template for Attendees, the "View Ticket" call-to-action button gets clobbered and routes to order summary page instead of view-ticket. Code was commented out for some reason, perhaps intentional? I changed it in my instance and now "View Ticket" correctly routes to "view ticket" page in presence of custom attendee email template.
State Before
Β Β Β Β
Notes
Β * This was discovered on a production instance where every attendee_ticket template's "View Ticket" button silently routed to the order summary page. After deploying this fix, the bug stops on first save; existing corrupted rows can either (a) be re-saved in the UI or (b) batched via the new artisan command.
Β
How I've tested these changes
Checklist