Skip to content

Maintain a resource file for the email template with placeholders - #40

Closed
anuragSharma1112 wants to merge 4 commits into
developfrom
resourceFile-emailTemplate-task26
Closed

Maintain a resource file for the email template with placeholders#40
anuragSharma1112 wants to merge 4 commits into
developfrom
resourceFile-emailTemplate-task26

Conversation

@anuragSharma1112

Copy link
Copy Markdown
Collaborator

Description

Added email template support for host notification.
Integrated hostNotification.txt template using EmailTemplateProcessor to dynamically generate email body with placeholders.

Fixes # (issue)
NA

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Database change

How Has This Been Tested?

  • Unit Tests
  • Integration Tests
  • Manual Testing (please describe)

Checklist:

  • I have created ADR (Architecture Decision Record) for this change, in case of architecture or tech stack changes.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes in other branches have been merged
  • I have updated the relevant application properties files (if needed)
  • I have updated any necessary database migrations (if needed)

Screenshots (for UX changes):

NA

Additional Notes:

Template file hostNotification.txt added under src/main/resources/templates/.
Updated unit tests to mock EmailTemplateProcessor for host email generation.

@anuragSharma1112

Copy link
Copy Markdown
Collaborator Author

Hi @axymthr sir, I have cut new branch and again giving the PR

@axymthr

axymthr commented Jul 16, 2025

Copy link
Copy Markdown
Contributor

Thanks. Please close the other PR.

@anuragSharma1112 anuragSharma1112 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

.

import com.statusneo.vms.model.Employee;
import com.statusneo.vms.model.Visitor;
import com.statusneo.vms.util.EmailTemplateProcessor;
import org.springframework.stereotype.Service;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

add author and license

String body = templateProcessor.loadTemplate("hostNotification.txt", placeholders);

Email email = Email.of(
"noreply@company.com",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

make it configurable

@@ -0,0 +1,80 @@
package com.statusneo.vms.config;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

add license

@anuragSharma1112

Copy link
Copy Markdown
Collaborator Author

Hi @axymthr sir please merge this Pull Request

@axymthr

axymthr commented Jul 25, 2025

Copy link
Copy Markdown
Contributor

@anuragSharma1112 merging is blocked due to merge conflicts. Can you rebase from branch from develop and push?

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.

These shouldn't be txt files. Use a standard template format. Since we already have JTE in this project use that instead.

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.

These shouldn't be txt files. Use a standard template format. Since we already have JTE in this project use that instead.

sender: noreply@company.com
visitor-confirmation:
subject: Registration Successful
template: visitorConfirmation.txt

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.

I'm not convinced about putting template location in here.
If you need to override it you'll still need to make code changes to add the new template and rebuild the application? what value does it add to put it in config?


@Component
public class EmailTemplateProcessor {
public String loadTemplate(String templateName, Map<String, String> placeholders) {

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.

All of this is unnecessary if we use JTE support. Spring/JTE should load it for you from standard class path location and do the rendering too.

@axymthr
axymthr deleted the resourceFile-emailTemplate-task26 branch November 29, 2025 10:29
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.

3 participants