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: processing sms and test tracker event deletion DHIS2-17729 #18473

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

teleivo
Copy link
Contributor

@teleivo teleivo commented Aug 28, 2024

  • Fixes bug: UserDetails refactoring broke SMS processing as SMS processing was done in another thread that does not have the currentUser set. The processing code uses the manager which requires the currentUser to be set.
  • Process incoming SMS via jobs instead to fix the above bug. Every incoming sms will result in a job executed as the user sending the sms.
  • Override MessageSender for Email and SmsMessageSender with FakeMessageSender so we can assert on error sms responses.
  • Test that we can delete a tracker event via an sms and that we respond with an sms if the event cannot be deleted.

The previous in-memory queue of unprocessed incoming sms is replaced by a queue of jobs (one per sms). We do not have any numbers on the sms usage. Android can use the tracker sms to send data to DHIS2 in case users are offline. According to @zubaira sms are costly and are therefore not that likely to be used frequently. We can optimize later if it turns out that we should rather batch sms processing into a single job.

Next

  • Enable the 2 disabled SmsOutboundControllerTests again. Untangle Email/SmsMessageSender. Most code is either dedicated to email or sms yet depends on MessageSender but then nugdes Spring to inject the email or sms sender. This does not make sense. I also could not get the test configuration to only override one or the other which is why I had to temporarily skip these 2 tests.
  • Use tracker importer in all tracker sms listeners.
  • Add more tests for sms processing. There are lots of classes involved in sms processing (deeper hierarchy) with indirection.
  • In a future task: make OutboundMessage a @Value class
  • In a future task: introduce generic error/warning SmsResponse codes so we can more easily map tracker errors to a response sms. Right now https://github.com/dhis2/sms-compression/blob/1cecf7d97cc4b80788fd3b4a17a0de09a53ed96a/src/main/java/org/hisp/dhis/smscompression/SmsResponse.java#L36 are very specific. Tracker has its own status codes and each import can have multiple errors we need to be able to map to a single short sms.

@teleivo teleivo force-pushed the DHIS2-17729 branch 12 times, most recently from 8d2998b to 770aa51 Compare September 3, 2024 07:21
Copy link
Contributor

@jbee jbee left a comment

Choose a reason for hiding this comment

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

Almost :) Just switch the ID for the job parameters to a UID String.

* UserDetails refactoring broke SMS processing as SMS processing was
  done in another thread that does not have the currentUser set. The
  processing code uses the manager which requires the currentUser to be
  set.
* Process incoming SMS via jobs instead to fix the above. Every incoming
  sms will result in a job executed as the user sending the sms.
* Return the IncomingSms UID instead of id from POST /sms/inbound
* Override MessageSender for Email and SmsMessageSender with
  FakeMessageSender so we can assert on error sms responses.
* Test that we can delete a tracker event via an sms and that we
  respond with an sms if the event cannot be deleted.
@teleivo teleivo marked this pull request as ready for review September 3, 2024 12:04
Copy link

sonarcloud bot commented Sep 3, 2024

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