-
Notifications
You must be signed in to change notification settings - Fork 76
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
[PHEE-296A] Email api #79
base: master
Are you sure you want to change the base?
Conversation
@Valid @RequestBody EmailRequestDTO emailRequest | ||
) { | ||
if (platformTenantId == null || platformTenantId.isEmpty()) { | ||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Platform-Tenant-Id header is missing"); |
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.
Supported param validations(etc: email regex) and basic field validations are missing.
Supported header validations are missing.
Error message not in the right format.
@NotEmpty | ||
private String subject; | ||
|
||
@NotEmpty |
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.
These annotation validations to be handled and sent in phee/fineract specific format.
|
||
// Getters and setters | ||
|
||
public List<String> getTo() { |
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.
use Lombok for getters and setters
@Autowired | ||
private JavaMailSender mailSender; | ||
|
||
@Value("${spring.mail.host}") |
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.
why do we have to specify 'spring' here? looks like an overhead. we are not using this anywhere else.
boolean flag = false; | ||
String error = null; | ||
try{ | ||
((JavaMailSenderImpl) mailSender).setHost(smtpHost); |
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.
Severe issue:
The values and the mail sender are global( available at startup). Setting those everytime when the API is called is a bad design. This should be created once and reused. My suggestion is to use mailSender bean with these properties use here.
|
||
|
||
} | ||
private ClientHttpRequestFactory createTimeoutRequestFactory() { |
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.
could not find a usage for this method.
Again, the rest template should be create as a bean with these settings so that we don't need t create it on the fly every time.
As rest template is going to be deprecated, better stick with webclient / retroft. There is already one implementation added to connector common
EmailService emailService; | ||
|
||
@PostMapping | ||
public ResponseEntity<String> sendEmail( |
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.
API documentation missing
@@ -22,6 +22,18 @@ spring: | |||
password: ${MYSQL_PASSWORD:password} | |||
driver-class-name: org.drizzle.jdbc.DrizzleDriver | |||
|
|||
mail: |
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.
Can you attach a demo video with Gmail settings to show that the email is sending successfully with Gmail?
@@ -54,6 +54,9 @@ ext { | |||
dependencies { | |||
implementation("org.springframework.boot:spring-boot-starter-web:2.5.5") | |||
implementation("org.springframework.boot:spring-boot-starter-actuator:$springBootVersion") | |||
implementation ("org.springframework.boot:spring-boot-starter-validation:$springBootVersion") | |||
implementation 'org.springframework.boot:spring-boot-starter-mail' | |||
testImplementation 'org.springframework.boot:spring-boot-starter-test' |
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.
why do we need this dependency, I could not find any tests below
@@ -54,6 +54,9 @@ ext { | |||
dependencies { | |||
implementation("org.springframework.boot:spring-boot-starter-web:2.5.5") | |||
implementation("org.springframework.boot:spring-boot-starter-actuator:$springBootVersion") | |||
implementation ("org.springframework.boot:spring-boot-starter-validation:$springBootVersion") |
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.
these validations may not produce error messages in our custom format. Please be careful with that
emailService.sendEmail(emailRequest,callbackUrl); | ||
|
||
return ResponseEntity.status(HttpStatus.ACCEPTED).body("Email accepted to be sent"); | ||
} |
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.
send response in JSON format
Description
New email api based on spec
The tc design is added in linked pr openMF/ph-ee-integration-test#293
[]
.Format:
[jira_ticket] description
ex: [phee-123] PR title.
Attached with this is the screenshot of TC passing locally
and

Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Followed the PR title naming convention mentioned above.
Design related bullet points or design document link related to this PR added in the description above.
Updated corresponding Postman Collection or Api documentation for the changes in this PR.
Created/updated unit or integration tests for verifying the changes made.
Added required Swagger annotation and update API documentation with details of any API changes if applicable
Followed the naming conventions as given in https://docs.google.com/document/d/1Q4vaMSzrTxxh9TS0RILuNkSkYCxotuYk1Xe0CMIkkCU/edit?usp=sharing