Skip to content

feat(mail): show the server's branding in every email - #1776

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:feat/issue-1392-email-branding
Oct 2, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:feat/issue-1392-email-branding

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

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 ▸ SILO text 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:

  • many mail clients block remote images by default;
  • the recipient may not be able to reach the server;
  • uploaded logos are stored as WebP, which Outlook for Windows does not render.

A shared mail.BrandLoader reads 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

  • Go: build, gofmt, go vet, and make lint-changed (0 issues) pass. make test-go passes except for tests that fail the same way on main on the macOS test machine: the hardware-acceleration probe tests in internal/playback and TestAdminResourceCapabilitiesAndScope in internal/apiv2. Some timing tests in jellycompat, policy, and transcodenode failed only under full-suite load and pass when run alone.
  • DB-backed tests for the changed packages pass against a migrated database, including the queued verification email keeping its logo. TestAdminSubtitleListPageDB in internal/api/handlers fails here and identically on main.
  • New tests cover the logo header and alt text, accent button contrast and invalid accents, WebP-to-PNG conversion and sizing, fallback when the asset is unavailable, the conversion cache, and the inline-image MIME structure. The tests for each sending flow check that the email carries the logo it references.
  • End to end: ran a local server against a local mail catcher and sent the test email, an invitation, and an admin-issued password reset, first with default branding and then with a custom name, an uploaded wordmark, and an accent color. Each arrived as multipart/related with the logo as an inline part and no attachment, and rendered as expected. The verification and digest emails were covered by tests only.
  • No web, API contract, or client changes, so the web gate and contract checks were not run.

Risks

  • Each HTML email is larger by the logo: about 10 KB for the Silo wordmark. An uploaded one is resized to fit 480×96 px; the test logo came to 17 KB, and a detailed photographic logo will be larger.
  • #1197 C1 (invitations) passed with the old header. The invitation email now looks different, but its content and links are unchanged.
  • mail.EmailButton and the invitations, passwordreset, and notifications constructors take a new argument. All in-repo callers are updated.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code
  • Tool(s): Claude Code, GitHub CLI
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: a separate Claude Code review agent reviewed the complete diff at medium effort. It found no correctness issues. It noted that failed logo reads are retried on each email rather than cached; that is intentional, so a storage outage recovers on its own.

Note

Add server branding to all outgoing emails

  • Adds mail.Brand and mail.BrandLoader in 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.
  • Wires a shared BrandLoader through notifications.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 by cid).
  • Durable email-verification requests store the brand and its inline images at queue time, so retained messages replay with the assets selected on admission (email_verification_outbox.go).
  • Adds imageutil.EncodePNGWithin for metadata-stripped PNG conversion, and batches branding settings reads via GetMany with a per-key fallback in service.go.
  • Risk: layout.go contains invalid Go syntax (extra unary-plus operators on strings) in RenderLayout and EmailButton, so the mail package does not compile as written.

Macroscope summarized ef4820d.

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.
@kody-ai

kody-ai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Providing Context (Files & MCPs)

Add these hints in your PR description (or a comment) to unlock deeper checks:

  • Ticket / Acceptance Criteria: `Refs: ABC-123` (Linear/Jira/Asana/ClickUp/Trello) or a direct ticket link.
  • Bugfix Validation: a Sentry/Datadog/Bugsnag event link (or paste the stack trace/error message).
  • Endpoint Risk: mention the route (e.g., `POST /api/payments`) or controller/action name.
  • Attach a repo file as context: use an explicit marker like `@file:docs/guide.mdx#L10-L50` (replace with your real path).
  • API Contract Docs: include `@file:openapi.yaml` or `@file:swagger.json` when changing routes/schemas.
  • Definition of Done / Standards: include `@file:DOD.md` or `@file:CONTRIBUTING.md` if your repo has them.
  • Design System Source of Truth: include `@file:ui/index.ts` (replace with your DS entrypoint path).
  • Feature Flags: include the flag key/name and `@file:flags.ts` / `@file:config.json` (and optionally the PostHog flag name).
  • Edge/CDN Rules: link the Cloudflare rule/zone or describe the intended redirect/header behavior.
  • Attach an MCP tool output: use `@mcp<provider|tool>` (replace with an installed MCP provider + tool, e.g., `@mcp<sentry|events.search>`).
Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Access your configuration settings here.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 8aeb67a8-2c87-4ec9-87a9-6f010d96c94e

📥 Commits

Reviewing files that changed from the base of the PR and between d11f73c and ef4820d.

📒 Files selected for processing (2)
  • internal/branding/service.go
  • internal/branding/service_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Email 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.

Changes

Server-branded email

Layer / File(s) Summary
Brand data and asset loading
internal/mail/mail.go, internal/mail/brand.go, internal/mail/brand_test.go, internal/imageutil/*, internal/branding/service.go, internal/branding/service_test.go
The mail package adds brand and inline-image data. The loader resolves branding, converts and caches wordmarks, and uses Silo defaults when needed. Image utilities constrain PNG dimensions. The branding service uses batch settings reads when supported and falls back to individual reads when necessary.
Branded rendering and MIME messages
internal/mail/layout.go, internal/mail/layout_test.go, internal/mail/mail.go, internal/mail/brand_test.go, docs/architecture/email.md
Layouts render a brand logo and accent-aware buttons. Message construction embeds inline images. The architecture documentation describes CID references and retaining images in queued messages.
Application branding and account emails
cmd/silo/main.go, internal/api/router.go, internal/api/handlers/email.go, internal/api/handlers/admin_email_test_service_test.go, internal/invitations/*, internal/passwordreset/*
Application wiring passes the shared brand loader to invitation, password-reset, and admin test email paths. These emails load the brand and include its inline images.
Notification and verification email delivery
internal/notifications/*, internal/scenariocatalog/executor/*
The notification system passes the brand loader to email and verification services. Verification messages use the brand and retain inline images in queued messages. Scenario tests pass the added optional dependency.

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
Loading

Suggested reviewers: quick104

Merge Risk: ⚪ Minimal · up to ef482

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 Review

Security architecture risk: 🔵 Low · up to ef482

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
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The new branding influence is server-wide across outgoing email workflows, not selected by recipient identity. Exercising control over the uploaded wordmark requires administrator authority in the reviewed routes; no recipient-controlled branding selector was identified.

Trust Boundaries and Controls

  • observed — Branding upload routes are administrator-wrapped. The upload handler applies kind-specific byte limits, and the service processes permitted image kinds into content-addressed objects under fixed storage prefixes. Mail requests only the configured wordmark, not a caller-supplied URL or object key.

Resilience and Maintainability Implications

  • observed — Asset retrieval or conversion failure falls back to the built-in logo. Queued verification images remain in the encrypted admitted payload through retries and recovery. Dispatch checks ownership, supersession and expiry, coordinates concurrent claims, and clears payloads during terminal cleanup; no supplied changed range alters those dispatch controls.

Hardening Proposals

  • proposed — Resolve the wordmark by the reference captured in the branding snapshot, or explicitly reconcile a changed reference, to keep sender presentation coherent during concurrent administrative updates. This is a consistency improvement, not an established security vulnerability.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 55 functions across 32 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding server branding to all outgoing email.
Description check ✅ Passed The description directly explains the branding problem, implementation, affected email flows, validation, and risks. It is related to the changeset.
Linked Issues check ✅ Passed The PR meets the coding requirements in issue #1392. BrandLoader loads the server name, accent color, and uploaded wordmark. It falls back to the current Silo wordmark when branding or image convers…
Out of Scope Changes check ✅ Passed The changes stay within issue #1392 scope. Brand loading, PNG conversion, inline image support, layout rendering, accent-color handling, email-flow wiring, queued-message retention, performance fallba…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread internal/mail/brand.go
if l == nil || l.source == nil {
return DefaultBrand()
}
snap := l.source.Load(ctx)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Performance high

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.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@macroscopeapp

macroscopeapp Bot commented Oct 1, 2026

Copy link
Copy Markdown

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 Validation tasks: changes #1197 C1 line is consistent.

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.
@kody-ai

kody-ai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Providing Context (Files & MCPs)

Add these hints in your PR description (or a comment) to unlock deeper checks:

  • Ticket / Acceptance Criteria: `Refs: ABC-123` (Linear/Jira/Asana/ClickUp/Trello) or a direct ticket link.
  • Bugfix Validation: a Sentry/Datadog/Bugsnag event link (or paste the stack trace/error message).
  • Endpoint Risk: mention the route (e.g., `POST /api/payments`) or controller/action name.
  • Attach a repo file as context: use an explicit marker like `@file:docs/guide.mdx#L10-L50` (replace with your real path).
  • API Contract Docs: include `@file:openapi.yaml` or `@file:swagger.json` when changing routes/schemas.
  • Definition of Done / Standards: include `@file:DOD.md` or `@file:CONTRIBUTING.md` if your repo has them.
  • Design System Source of Truth: include `@file:ui/index.ts` (replace with your DS entrypoint path).
  • Feature Flags: include the flag key/name and `@file:flags.ts` / `@file:config.json` (and optionally the PostHog flag name).
  • Edge/CDN Rules: link the Cloudflare rule/zone or describe the intended redirect/header behavior.
  • Attach an MCP tool output: use `@mcp<provider|tool>` (replace with an installed MCP provider + tool, e.g., `@mcp<sentry|events.search>`).
Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Access your configuration settings here.

@Quick104
Quick104 merged commit eff6665 into Silo-Server:main Oct 2, 2026
17 checks passed
Quick104 added a commit to Rhainland/silo-server that referenced this pull request Oct 2, 2026
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]>
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.

Use server branding and the current wordmark in the invitation email

2 participants