Skip to content

updated the mail sending functionality for DEV env and seperated the DEV and PROD env execution#20

Closed
NeonShivam wants to merge 6 commits intodevelopfrom
test_shivam
Closed

updated the mail sending functionality for DEV env and seperated the DEV and PROD env execution#20
NeonShivam wants to merge 6 commits intodevelopfrom
test_shivam

Conversation

@NeonShivam
Copy link
Copy Markdown
Collaborator

in this PR changes made are -

  1. cleaning of mailSender.java, removed not used methods
  2. seperated the execution of project based on environments i.e. DEV and PROD
  3. for PROD env MS365 APIs will be used for DEV only file logs will be done

@NeonShivam NeonShivam requested a review from axymthr June 13, 2025 06:01
@NeonShivam NeonShivam self-assigned this Jun 13, 2025
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.

Don't do this. We don't need to containerize our service, but if we do, use Buildpack support which is bundled in. This kind of flat Dockerfile is not appropriate for Spring Boot apps.

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.

ok, I will check and work on this

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.

We already have a compose.yaml. Any changes should go into that. I also want to understand the motivation behind this. Is this for our dev workflow (i.e. container based development)? What is this addition buying us?

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.

Now I have put everything inside docker-compose.yml for now

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.

There are too many structural changes in this file, where I'm not sure what the actual addition/removal is. Unfortunately we don't (yet) have a robust automated PR checker which would just flag actual issues so we don't need to review this file. Until then, changes need to be made judiciously or explained.

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.

ok


@Autowired
private EmailService emailService;
private EmailService emailService; // Ensure this is autowiring the INTERFACE
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.

The point of autowiring is Spring injects the implementation.
I don't see anyway you would be able to enforce this comment anyhow.

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 know you weren't working on this aspect yet, but the real code smell here is the direct call to EmailService from the controller. Sending email is an outcome of a business process, this call should be made from inside one of the other services.

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.

I have now used the method saveVisitor to send mail which is inside VisitService


void sendMeetingNotification(String email, String whomToMeet);

// Optional: for QA to inspect sent emails (only relevant for the mock)
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.

You've just hit on my exact issue with "design for testability" approach. It messes up the interfaces. I don't have a cleaner approach in mind for this right now, we can keep this for now.

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.

ok

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.

My problem with this class is it's violating SOLID. There is only 1 responsibility - the mechanic of sending emails. Everything else needs to be pulled out to other classes/interfaces. It doesn't matter whether it's an OTP or an alert or a report, for this interface it's just an email send operation. The clients have to send the right payloads.

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.

I have now seperated the interfaces and created specific to functionality like
EmailService,
OtpNotificationService,
VisitorNotificationService,
MeetingNotificationService,
VisitorReportService

properties:
hibernate:
format_sql: true
datasource:
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.

This shouldn't be necessary. The prescribed mechanism for dev DB connections is to use Spring Boot Service Connections (is that the correct name?) which are auto injected. If you want to use a local DB, that's fine, but don't commit it, specially credentials.

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.

ok

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.

Don't comment this. It took me a week to bring this back after the last dev commented it out. It works fine, you need to tune your setup so it works for you.

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.

ok

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.

Don't comment this. It took me a week to bring this back after the last dev commented it out. It works fine, you need to tune your setup so it works for you.

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.

ok

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.

Don't commit commented out tests. Test should run and pass before code is committed.

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.

ok

@NeonShivam NeonShivam requested a review from axymthr June 17, 2025 09:50
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.

2 participants