Repository navigation
fix(email): share branding with the reminder worker (#167) - #168
Merged
Merged
Conversation
Reminder emails rendered <img src="/branding/logo?v=..."> because the worker read logo_url straight out of server_settings, skipping the relative->absolute step that applyBranding performs for confirmations, cancellations and reschedules. Mail clients cannot resolve a relative path, so the logo vanished and the banner was never loaded at all. The cause was structural: applyBranding/loadBranding were methods on handler.Handler, and the worker is a separate package, so it could not call them. Move the brand identity into internal/branding (Load + ApplyTo) and have both senders use it. handler keeps thin loadBranding/applyBranding wrappers so its call sites are unchanged; brandingSettings is an alias of the shared type. The worker now takes the booker-facing base URL via WithPublicURL, wired in server.go with the same PUBLIC_BASE_URL -> BaseURL fallback handler.publicURL() uses. Regression test asserts the rendered reminder carries absolute logo and banner URLs and no relative branding path; it fails against the pre-fix worker.
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
internal/brandingextraction —Settings,Load, andApplyTonow own loading and stamping, including the relative → absolute asset URL conversion that #167 was missing.- Handler wrappers —
brandingSettingsbecame an alias andloadBranding/applyBrandingdelegate to the new package, so the existing call sites are unchanged. - Worker wiring —
WithPublicURLmirrorshandler.publicURL()'sPUBLIC_BASE_URL→BaseURLfallback, andsendRemindernow uses the shared loader instead of its own query. - Regression test — asserts absolute logo/banner URLs and the business name in rendered reminder HTML, plus no relative
src="/branding/fallback.
deepseek-v4.1-flash | 𝕏
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.

Closes #167.
The bug
Reminder emails rendered
<img src="/branding/logo?v=...">and never showed the banner. Your diagnosis was correct.The structural cause:
applyBranding/loadBrandingwere methods onhandler.Handler, so the background worker (a separate package) could not call them.sendReminderdid its own two-column query and scanned straight into the email data — no relative→absolute URL step, no banner, no logo height/opacity.The fix
Moved the brand identity into a new
internal/brandingpackage:branding.Load(ctx, db) Settings— the single loader.Settings.ApplyTo(d *mailer.BookingData, baseURL)— the single stamper, including the relative→absolute conversion.Both senders now use it:
loadBranding/applyBrandingwrappers, so all 14 existing call sites are untouched.brandingSettingsis now an alias ofbranding.Settings.branding.Load(...).ApplyTo(...)insendReminder.The worker needs the public base URL, so it takes
worker.WithPublicURL, wired inserver.gowith the samePUBLIC_BASE_URL→BaseURLfallback thathandler.publicURL()uses. That keeps the two in agreement.One small behaviour improvement along the way: the join trims a trailing slash on the base URL, so
https://host/no longer produceshttps://host//branding/logo.Test
TestWorker_reminderEmailCarriesAbsoluteBrandingininternal/worker/reminder_test.go. It seeds branding with relative paths, runs a reminder job, and asserts the HTML containssrc="https://book.example.com/branding/logo?v=42"src="https://book.example.com/branding/banner?v=43"src="/branding/fallback.I confirmed it fails against the pre-fix worker before keeping it.
go test ./...green.🤖 Generated with Claude Code