-
Notifications
You must be signed in to change notification settings - Fork 498
Email templates reset fix #1024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughChanges add type safety to email configuration and enforce that custom email templates are only preserved when using dedicated (non-shared) SMTP servers. The conditional template handling is validated through a new E2E test and implemented in the config sanitization schema. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Email Config Update
participant Schema as sanitizeOrganizationConfig
participant Templates as Email Templates Store
Client->>Schema: updateConfig with emails.server
alt isShared = false (Dedicated Server)
Schema->>Templates: Merge & preserve prepared.emails.templates
Templates->>Templates: Custom templates retained
else isShared = true (Shared Server)
Schema->>Templates: Omit prepared.emails.templates
Templates->>Templates: Custom templates removed
end
Schema->>Client: Sanitized config returned
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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 |
Greptile OverviewGreptile SummaryThis PR fixes the email templates reset issue by ensuring custom email templates are only included when using a dedicated email server ( Key Changes
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant Dashboard
participant API
participant Schema
participant Database
User->>Dashboard: Update email server config
Dashboard->>API: PATCH /api/v1/internal/config/override
Note over Dashboard,API: Sets isShared = true/false
API->>Database: Store config override
Database-->>API: Config saved
User->>Dashboard: Request config
Dashboard->>API: GET /api/v1/internal/config
API->>Database: Fetch config
Database-->>API: Raw config
API->>Schema: sanitizeOrganizationConfig(config)
alt isShared = true
Schema->>Schema: Exclude custom templates<br/>(use only DEFAULT_EMAIL_TEMPLATES)
else isShared = false
Schema->>Schema: Include custom templates<br/>(merge with DEFAULT_EMAIL_TEMPLATES)
end
Schema-->>API: Sanitized config
API-->>Dashboard: Config with/without templates
Dashboard-->>User: Display config
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, no comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/stack-shared/src/config/schema.ts (1)
755-755: Consider usingprepared.emails.server.isSharedfor consistency.The conditional logic correctly filters out custom templates when using a shared server. However, since line 748 already prepares the sanitized config and the rest of the function uses
preparedfor similar checks, it would be more consistent to referenceprepared.emails.server.isSharedinstead ofconfig.emails.server.isShared.While functionally equivalent (since
isSharedisn't transformed by sanitization), usingpreparedthroughout maintains a consistent pattern.const templates: typeof prepared.emails.templates = { ...DEFAULT_EMAIL_TEMPLATES, - ...(config.emails.server.isShared ? {} : prepared.emails.templates), + ...(prepared.emails.server.isShared ? {} : prepared.emails.templates), };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/emails/page-client.tsx(1 hunks)apps/e2e/tests/backend/endpoints/api/v1/internal/config.test.ts(2 hunks)packages/stack-shared/src/config/schema.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
apps/e2e/tests/backend/endpoints/api/v1/internal/config.test.ts (3)
apps/e2e/tests/helpers.ts (1)
it(12-12)packages/stack-shared/src/helpers/emails.ts (1)
DEFAULT_EMAIL_THEME_ID(107-107)apps/e2e/tests/backend/backend-helpers.ts (1)
niceBackendFetch(109-173)
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/emails/page-client.tsx (1)
packages/stack-shared/src/config/schema.ts (1)
CompleteConfig(1074-1074)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Vercel Agent Review
- GitHub Check: all-good
- GitHub Check: lint_and_build (latest)
- GitHub Check: build (22.x)
- GitHub Check: docker
- GitHub Check: restart-dev-and-test
- GitHub Check: build (22.x)
- GitHub Check: setup-tests
- GitHub Check: restart-dev-and-test-with-custom-base-port
- GitHub Check: build (22.x)
- GitHub Check: check_prisma_migrations (22.x)
🔇 Additional comments (3)
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/emails/page-client.tsx (1)
158-158: LGTM! Type safety improvement.The
satisfiesassertion ensures the email server configuration object conforms toCompleteConfig['emails']['server']at compile time, helping catch any structural mismatches early.apps/e2e/tests/backend/endpoints/api/v1/internal/config.test.ts (2)
1-1: LGTM! Necessary import for the new test.The
DEFAULT_EMAIL_THEME_IDconstant is correctly imported and used in the test to ensure the custom template references a valid theme.
536-633: LGTM! Comprehensive test coverage for template filtering behavior.This end-to-end test thoroughly validates the new behavior:
- Dedicated server scenario (lines 575-601): Confirms custom templates are preserved when using a dedicated SMTP server
- Shared server scenario (lines 603-618): Verifies custom templates are filtered out from the rendered config when switching to shared
- Round-trip scenario (lines 620-632): Ensures templates reappear when switching back to dedicated, confirming they're stored in the database but conditionally rendered
The test design with helper functions (
configureServer,upsertTemplate) promotes clarity and maintainability.
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.