Skip to content
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

feat(VIST-CPC-811): send email on visit request #589

Merged
merged 11 commits into from
Oct 23, 2023

Conversation

swafit
Copy link
Collaborator

@swafit swafit commented Oct 23, 2023

JIRA: link to jira ticket

Context:

Sending an email to the pet owner when a visit is requested/scheduled.

Changes

Added AuthServiceClient and mailerClient integration to be able to send emails.

Before and After UI (Required for UI-impacting PRs)

Image of an email sent when a visit is added.
image

Dev notes (Optional)

  • Changed 1 line in auth to fix a deprecated use of an api in the AuthMailServiceTests for the Auth team.

@github-actions
Copy link

github-actions bot commented Oct 23, 2023

Qodana for JVM

374 new problems were found

Inspection name Severity Problems
Unused import 🔶 Warning 103
Redundant character escape 🔶 Warning 85
Dangling Javadoc comment 🔶 Warning 15
Invalid YAML configuration 🔶 Warning 11
Integer multiplication or shift implicitly cast to 'long' 🔶 Warning 10
AutoCloseable used without 'try'-with-resources 🔶 Warning 6
Optional.get() is called without isPresent() check 🔶 Warning 6
Default annotation parameter value 🔶 Warning 5
Field can be local 🔶 Warning 5
Redundant local variable 🔶 Warning 5
Nullability and data flow problems 🔶 Warning 4
Deprecated API usage 🔶 Warning 4
Link specified as plain text 🔶 Warning 4
@NotNull/@Nullable problems 🔶 Warning 4
Spring Data repository method parameters errors 🔶 Warning 4
Unused assignment 🔶 Warning 4
Possibly blocking call in non-blocking context 🔶 Warning 3
Call to 'printStackTrace()' 🔶 Warning 3
'Optional' used as field or parameter type 🔶 Warning 2
Unused publisher 🔶 Warning 2
Redundant type cast 🔶 Warning 2
Redundant 'close()' 🔶 Warning 2
Calling 'subscribe' in "reactive" methods 🔶 Warning 1
Field may be 'final' 🔶 Warning 1
Lombok @Getter may be used 🔶 Warning 1
Mismatch in @PathVariable declarations and usages 🔶 Warning 1
Begin or end anchor in unexpected position 🔶 Warning 1
'size() == 0' can be replaced with 'isEmpty()' 🔶 Warning 1
Unnecessary call to 'toString()' 🔶 Warning 1
Commented out code ◽️ Notice 35
Duplicated code fragment ◽️ Notice 19
Non recommended 'field' injections ◽️ Notice 19
Constant values ◽️ Notice 2
Mismatch in @PathVariable declarations and usages ◽️ Notice 1
Throw statement in Reactive operator ◽️ Notice 1
Regular expression can be simplified ◽️ Notice 1

☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

Comment on lines +17 to +29
public Mono<? extends Throwable> rethrow(ClientResponse clientResponse, Function<Map, ? extends Throwable> exceptionProvider) {
return clientResponse.createException().flatMap(n ->
{
try {
final Map map =
objectMapper.readValue(n.getResponseBodyAsString(), Map.class);
return Mono.error(exceptionProvider.apply(map));
} catch (JsonProcessingException e) {
// e.printStackTrace();
return Mono.error(e);
}
});
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you clarify what this method is doing and why you need it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It rethrows error to what called it. I need it because of how the authServiceClient was implemented(copied from the api-gateway).

@MichaelVacca MichaelVacca added feat New feature or request VIST Visits team labels Oct 23, 2023
@@ -80,11 +88,20 @@ public Mono<VisitResponseDTO> addVisit(Mono<VisitRequestDTO> visitRequestDTOMono
.then(validatePetId(visitRequestDTO.getPetId()))
.then(validateVetId(visitRequestDTO.getPractitionerId()))
.then(Mono.just(visitRequestDTO))
.doOnNext(s->{

authServiceClient.getUserById(visitRequestDTO.getJwtToken(), visitRequestDTO.getOwnerId()).subscribe(user->mailService.sendMail(generateVisitRequestEmail(user, visitRequestDTO.getPetId(), visitRequestDTO.getVisitDate())));
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you explain what .subscribe () is doing here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It allows to run code once we get the return from the asynchronous getUserById method from the AuthServiceClient. In this case, it is a non blocking way to wait to get the user, then go ahead with sending the email.

Copy link
Collaborator

@CptDoritos CptDoritos left a comment

Choose a reason for hiding this comment

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

This passes the Vibe Check
(Please don't Kill me Dylan)

@swafit swafit merged commit dbc92c9 into main Oct 23, 2023
3 checks passed
@swafit swafit deleted the feat/VIST-CPC-811_Send_Email_On_Visit_Request branch October 23, 2023 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request VIST Visits team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants