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

fix: Unable to save outbound sms during async operation [DHIS2-18586] #19415

Merged
merged 5 commits into from
Dec 13, 2024

Conversation

zubaira
Copy link
Contributor

@zubaira zubaira commented Dec 10, 2024

DHIS2-18586

Async operation tries to save outboundSMS and it fails due to currentUser not set. This PR injects currentUser using AuthenticationService.

@zubaira zubaira requested a review from a team December 11, 2024 20:26
Copy link

sonarcloud bot commented Dec 11, 2024

@@ -292,7 +286,12 @@ private void handleResponse(OutboundMessageResponse status, OutboundSms sms) {
sms.setStatus(OutboundSmsStatus.FAILED);
}

outboundSmsService.save(sms);
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

Who is calling this method?
Why the user is not present?
This doesn't seem to be running in another thread, if I am wrong, who is starting the thread?

Copy link
Contributor Author

@zubaira zubaira Dec 12, 2024

Choose a reason for hiding this comment

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

Who is calling this method?

Why the user is not present?
because this is an async operation.
Screenshot 2024-12-12 at 19 10 50

This doesn't seem to be running in another thread, if I am wrong, who is starting the thread?

@@ -122,7 +123,7 @@ public OutboundMessageResponse sendMessage(
public Future<OutboundMessageResponse> sendMessageAsync(
String subject, String text, String footer, User sender, Set<User> users, boolean forceSend) {
OutboundMessageResponse response = sendMessage(subject, text, footer, sender, users, forceSend);
return new AsyncResult<>(response);
return CompletableFuture.completedFuture(response);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is doing nothing, it is not running sendMessage in a different thread and it is not running it in parallel.
Would it make sense to just return the response?

@zubaira zubaira merged commit ad491fb into master Dec 13, 2024
16 checks passed
@zubaira zubaira deleted the DHIS2-18586-dev branch December 13, 2024 12:20
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