Repository navigation
feat(mail): show the server's branding in every email - #1776
Conversation
The shared email layout drew a hard-coded "▸ SILO" text header that ignored server branding and predated the current Silo wordmark. The header now shows the uploaded wordmark, or the current Silo wordmark when none is set, with the server name as alt text. A configured accent color colors the primary button, with a dark or white label for contrast. The logo is embedded in each message as an inline PNG rather than linked: mail clients often block remote images, recipients may not reach the server, and uploaded logos are stored as WebP, which Outlook does not render. A shared BrandLoader converts the wordmark once per content ref and falls back to the Silo wordmark when the asset cannot be read, so branding never blocks a send. Applies to invitations, password resets, the admin test email, address verification, and notification emails.
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Providing Context (Files & MCPs)Add these hints in your PR description (or a comment) to unlock deeper checks:
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughEmail messages now support inline images and server branding. A shared brand loader resolves the server name, accent color, and wordmark, with Silo defaults. Invitation, password-reset, admin test, notification, and verification emails use the brand. Queued verification messages retain inline assets. ChangesServer-branded email
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~45 minutes Change: Feature · Severity of issue fixed: Low Sequence Diagram(s)sequenceDiagram
participant InvitationService
participant BrandLoader
participant InvitationComposer
participant RenderLayout
participant MailSender
InvitationService->>BrandLoader: Load brand
InvitationService->>InvitationComposer: Compose invitation with brand
InvitationComposer->>RenderLayout: Render branded HTML
InvitationService->>MailSender: Send message with inline images
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change adds shared branding and inline logos to email delivery while preserving settings fallback behavior. No concrete merge-blocking issue is identified; merge after normal build and test checks pass. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Uploaded branding now reaches account and notification emails, including messages retained for retry. The reviewed paths restrict branding changes to administrators, constrain image handling, and preserve queued message contents. No material security regression was established, but incomplete comparison and coverage prevent a minimal-risk assessment. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| if l == nil || l.source == nil { | ||
| return DefaultBrand() | ||
| } | ||
| snap := l.source.Load(ctx) |
There was a problem hiding this comment.
Excessive database round trips in internal/mail/brand.go occur because BrandLoader.Load reloads the entire branding snapshot for every email and branding.Service.Load executes ten separate settings queries even when the converted logo is cached, adding 10N round trips for N emails during the notification recipient sweep while recipient transactions remain open. Cache the shared snapshot with bounded freshness/invalidation or load the email-specific settings in one batched query.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Fixed in ef4820d. branding.Service.Load now reads all branding settings with one GetMany query when the settings store supports it (the production EncryptedSettingsRepo does), and falls back to single reads otherwise. Each email now costs one settings query for branding instead of ten, and web page renders get the same saving. I did not add a time-based snapshot cache: settings changes would then take effect late, and on a multi-node deployment each node could serve stale branding.
There was a problem hiding this comment.
That addresses the original performance concern: batching the settings reads through GetMany was one of the suggested fixes, reducing branding queries from 10N to N for N emails on the production store.
Avoiding a time-based snapshot cache is reasonable here—it preserves fresh settings reads without introducing per-node staleness. The single-read fallback also preserves compatibility with other stores.
Based on your description of ef4820d20, I consider the suggestion addressed; no snapshot cache is needed for this fix.
|
Minor change: the invitation email checked in #1197 C1 now shows the server/Silo wordmark and may use the configured accent for its CTA; its content and claim link are unchanged. Please re-check the email’s appearance after merge. The PR’s Suggested fix: No diff — this is a post-merge validation follow-up, not a source defect. Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
Service.Load read its ten settings one query at a time. Every outgoing email now loads branding, including inside the notification sweep's per-recipient transaction, so read them with the settings store's GetMany when it has one, falling back to single reads.
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Providing Context (Files & MCPs)Add these hints in your PR description (or a comment) to unlock deeper checks:
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Resolves the regenerated contract digest in get_system_info_ok.json and passes the brand loader that Silo-Server#1776 added to NewService in this branch's PostgreSQL invitation tests. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Problem
Closes #1392
Related issue: #1226
Validation tasks: changes #1197 C1
Silo's emails ignore the server's branding. Every HTML email (invitations, password resets, the admin test email, address verification, and notification emails) starts with a hard-coded
▸ SILOtext header. It shows neither the logo an admin uploaded nor the current Silo wordmark. Someone invited to a branded server gets an email that looks like it came from a different product.This change puts the server's uploaded wordmark in the header of every email, or the current Silo wordmark when none is set, with the server name as alt text. When an accent color is set, the email's main button uses it, as the web app's primary buttons do.
Approach
All of these emails share one layout in
internal/mail, so the header and button change there once. The header follows the web sidebar: the uploaded wordmark, else the Silo wordmark. It never falls back to the square icon. The button label is dark or white, whichever reads better on the accent. An accent value that is not a hex color is ignored.The logo is embedded in each message as an inline PNG (
cid:) rather than linked from the server, for three reasons:A shared
mail.BrandLoaderreads the branding and converts the wordmark to PNG once per uploaded image. If the asset cannot be read or converted, it logs a warning and uses the Silo wordmark, so branding problems never stop an email from sending. Queued address-verification emails store their logo with the rest of the message, so a retry sends what was queued.The branding service is now created before the notification system in
cmd/silo/main.go, because notifications send email.Validation
gofmt,go vet, andmake lint-changed(0 issues) pass.make test-gopasses except for tests that fail the same way onmainon the macOS test machine: the hardware-acceleration probe tests ininternal/playbackandTestAdminResourceCapabilitiesAndScopeininternal/apiv2. Some timing tests injellycompat,policy, andtranscodenodefailed only under full-suite load and pass when run alone.TestAdminSubtitleListPageDBininternal/api/handlersfails here and identically onmain.multipart/relatedwith the logo as an inline part and no attachment, and rendered as expected. The verification and digest emails were covered by tests only.Risks
#1197 C1(invitations) passed with the old header. The invitation email now looks different, but its content and links are unchanged.mail.EmailButtonand theinvitations,passwordreset, andnotificationsconstructors take a new argument. All in-repo callers are updated.Checklist
AI Disclosure
Note
Add server branding to all outgoing emails
mail.Brandandmail.BrandLoaderin brand.go: resolves the server name, accent color, and wordmark from the branding service, converts custom logos to PNG at up to 2x display size, and caches them. Falls back to the embedded Silo wordmark when assets are missing.BrandLoaderthroughnotifications.NewSystem, the invitation and password-reset services, and the admin test-email handler. All emails now load the current brand, use it for layout and buttons, and attach its inline image (referenced bycid).imageutil.EncodePNGWithinfor metadata-stripped PNG conversion, and batches branding settings reads viaGetManywith a per-key fallback in service.go.RenderLayoutandEmailButton, so themailpackage does not compile as written.Macroscope summarized ef4820d.