Skip to content

fix(email): share branding with the reminder worker (#167) - #168

Merged
shockalotti merged 1 commit into
mainfrom
fix/reminder-email-branding
Oct 26, 2026
Merged

shockalotti merged 1 commit into
mainfrom
fix/reminder-email-branding

Conversation

@shockalotti

Copy link
Copy Markdown
Contributor

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/loadBranding were methods on handler.Handler, so the background worker (a separate package) could not call them. sendReminder did 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/branding package:

  • 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:

  • Handlers keep thin loadBranding/applyBranding wrappers, so all 14 existing call sites are untouched. brandingSettings is now an alias of branding.Settings.
  • The worker calls branding.Load(...).ApplyTo(...) in sendReminder.

The worker needs the public base URL, so it takes worker.WithPublicURL, wired in server.go with the same PUBLIC_BASE_URL → BaseURL fallback that handler.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 produces https://host//branding/logo.

Test

TestWorker_reminderEmailCarriesAbsoluteBranding in internal/worker/reminder_test.go. It seeds branding with relative paths, runs a reminder job, and asserts the HTML contains

  • src="https://book.example.com/branding/logo?v=42"
  • src="https://book.example.com/branding/banner?v=43"
  • the business name, and
  • no src="/branding/ fallback.

I confirmed it fails against the pre-fix worker before keeping it.

go test ./... green.

🤖 Generated with Claude Code

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • internal/branding extraction — Settings, Load, and ApplyTo now own loading and stamping, including the relative → absolute asset URL conversion that #167 was missing.
  • Handler wrappers — brandingSettings became an alias and loadBranding/applyBranding delegate to the new package, so the existing call sites are unchanged.
  • Worker wiring — WithPublicURL mirrors handler.publicURL()'s PUBLIC_BASE_URL → BaseURL fallback, and sendReminder now 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.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash | 𝕏

@shockalotti
shockalotti merged commit a2bdcf1 into main Oct 26, 2026
10 checks passed
@shockalotti
shockalotti deleted the fix/reminder-email-branding branch October 26, 2026 04:38
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.

Reminder emails don't use branding - Possible culprit found

1 participant