Repository navigation
Conversation
|
Did you write this using an AI agent? |
My IDE is cursor so AI helped when I was stuck and helped me find the right files to be editing. (An AI agent very much wrote the lovely PR description though haha) |
|
This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged. |
a28f34d to
3860758
Compare
|
This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged. |
|
Hey, I don’t think we should implement this feature in the proposed way for the following reasons:
Also avoid updating the Helm files directly, as they are managed differently. |
Add TemplateEngine class with 17 template variables for dynamic email personalization. Includes variables like user_name, media_name, request_id, request_url, etc. Supports conditional rendering and provides foundation for custom templates. re seerr-team#1876
Add customTemplates object to NotificationAgentEmail interface. Support per-notification-type custom templates (subject, body, useCustomHtml). Include templates for all notification types: mediaPending, mediaApproved, mediaAvailable, mediaDeclined, etc.
Add Pug template files for custom email rendering. Includes custom-template for styled emails and raw-html for fully custom HTML emails. Supports both subject and body template rendering.
Integrate custom template logic into EmailAgent. Add shouldUseCustomTemplate and buildCustomMessage methods. Support both styled custom templates and raw HTML templates. Remove redundant fallback code and optimize for performance. re seerr-team#1876
Add API endpoints for template testing, preview, and variable information. Includes /email/test-template for sending test emails, /email/preview for template preview, and /email/template-variables for available variables and defaults. re seerr-team#1876
Add comprehensive email template editor with per-template customization. Features include toggle between default/custom modes, live preview, test email functionality, custom HTML support, template variables reference, and individual/bulk save operations. re seerr-team#1876
Add API documentation for new email template endpoints: test-template, preview, and template-variables. Include request/response schemas and proper endpoint definitions. re seerr-team#1876
3860758 to
e94ae5a
Compare
That is a fair point, is there a preferred standard template engine that I should look at implementing here? |
I already used handlebars for that kind of templating stuff, but I don't have much preference on this if someone has a better alternative in mind.
A custom template system has already been implemented with webhooks, both for the message content and the address (see https://github.com/seerr-team/seerr/blob/develop/server/lib/notifications/agents/webhook.ts). As we already implemented this custom template system, if it is enough for our use cases we could maybe look into adapting it for all notifications (instead of just the webhooks)? |
That makes sense, looking at the options I think it makes the most sense to use Handlebars. The webhook's KeyMap can't handle conditionals or formatting, and my custom engine only has basic conditional support. Handlebars gives us all that plus extensibility without reinventing the wheel. I'm thinking I would split this work over several PRs:
Does this align with what you're thinking? |
Ah, I didn't see you created a custom engine to do other things than just replacing placeholders. Yes it's either a very simple engine to replace placeholders (like right now), or another lib to handle it.
100% agree. The smaller the PRs, the better. Very big PR like this one are very hard to review. WDYT of something like this instead:
The order of 2. and 3. could be inverted. |
That makes sense to me, I'll get started on converting the web hooks engine to use handlebars |
|
First part is up #2039 I put extensive testing instructions to try and make the review process easier. |
|
@mmenanno If the PR linked above was meant to be opened directly against seerr, it looks like you accidentally created it in your fork instead. This one mmenanno#1 |
|
@M0NsTeRRR it is a stacked PR, so this PR #2039 needs to be merged first. I opened it against my fork just to have the description and such ready for when I can open it against the main repo |
Description
This PR implements a comprehensive custom email template system for Jellyseerr, enabling administrators to create personalized email notifications with dynamic variables and full customization control.
Key Features:
user_name,media_name,request_url,request_id,media_overview,current_date,user_request_count,days_pending,season_count,tmdb_id,imdb_id, and moreTechnical Implementation:
TemplateEngineclass with variable interpolation and conditional rendering ({{#is_4k}}support)/test-template,/preview, and/template-variablesfor comprehensive template managementcustom-template) and raw HTML (raw-html) renderingNotificationAgentEmailinterface with granularcustomTemplatesconfigurationUser Experience:
Supported Notification Types:
Screenshot (if UI-related)
Customize Templates button added to email notifications page:

Main template management page with multiple notification types:

Template editor:

Email preview modal showing rendered content:



Custom HTML mode interface:

To-Dos
pnpm buildpnpm i18n:extractIssues Fixed or Closed