Skip to content

Conversation

@shubham1g5
Copy link
Contributor

@shubham1g5 shubham1g5 commented Oct 28, 2025

Product Description

https://dimagi.atlassian.net/browse/CCCT-1805

Alternate approach to #3376 to consolidate common code and address the concern raised here

Review commit by commit for ease (Diff is quite bad as a whole due to renaming)

Technical Summary

Instead of having 2 different worker managers and workers for notifications sync, I am now using the existing framework to sync notifications. This also removes earlier code to sync messages as messages are now synced through the notifications worker itself.

Safety Assurance

Safety story

  • New feature which will be QA'ed with the impact limited to background processing of notifications

QA Plan

Part of https://dimagi.atlassian.net/browse/QA-8180

Labels and Review

  • Do we need to enhance the manual QA test coverage ? If yes, the "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, the "Release Note" label is set and a "Release Note" is specified in PR description.
  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@shubham1g5 shubham1g5 marked this pull request as ready for review October 28, 2025 17:03
@shubham1g5 shubham1g5 changed the title Merge notifications and messaging workers Periodic Notifications Sync Oct 28, 2025
private const val SYNC_BACKOFF_DELAY_IN_MILLIS: Long = 3 * 60 * 1000L // min 3 minutes
private const val NOTIFICATION_RETRIEVAL_PERIODIC_WORKER_TAG = "notification_retrieval_periodic_worker"
private const val PERIODICITY_FOR_NOTIFICATION_RETRIEVAL_IN_HOURS = 1L
private const val NOTIFICATION_RETRIEVAL_BACKOFF_DELAY_FOR_RETRIEVAL_RETRY = 10L
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Specify IN_MINUTES?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a long name already, so maybe just as a comment instead...

Copy link
Contributor Author

Choose a reason for hiding this comment

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



companion object {
private const val SYNC_BACKOFF_DELAY_IN_MILLIS: Long = 3 * 60 * 1000L // min 3 minutes
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Could just make it minutes here (like the other backoff below) to be more consistent as well as save some math

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 231 to 233
private fun startWorkRequest(notificationPayload: Map<String, String>, action: SyncAction, uniqueWorkName: String) {
startWorkRequest(notificationPayload, action, uniqueWorkName, syncType)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@shubham1g5 This method seems redundant and not required, can directly call second startWorkRequest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used Kotlin default params instead - 2dfd31b

Comment on lines 179 to 182
if (!isNotificationSyncScheduled) {
// we want to get info on pending notifications irrespective of whether there are notification related FCMs or not
startPersonalIdNotificationsWorker(emptyMap())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@shubham1g5 We should check signaling=true also as we want to sync only if push notification is related to connect and ignore for other types of notifications i.e. commcare

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Jignesh-dimagi there is no push notification payload to show for this sync (it's not coming from fcm but more of a post-fcm sync task)

Copy link
Contributor

Choose a reason for hiding this comment

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

@shubham1g5 I mean if application receives some commcare notification, its not required to call startPersonalIdNotificationsWorker so check for signaling=true which ensure that connect notification being received.

Also, this will again call the sync notification API from here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Handled it in here - 86ee025

notificationPayload,
SyncAction.SYNC_PERSONALID_NOTIFICATIONS,
SyncAction.SYNC_PERSONALID_NOTIFICATIONS.toString(),
SyncType.OTHER
Copy link
Contributor

Choose a reason for hiding this comment

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

@shubham1g5 In this case, it will never show the connect message push notification on tray. This should use the SyncType of the this class only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for catching, 402370e

@shubham1g5
Copy link
Contributor Author

@Jignesh-dimagi I am going to merge it in order to move ahead with this work but happy to take the conversation going and resolve it in the base PR.

@shubham1g5 shubham1g5 merged commit af9c8c1 into syncNotifications Oct 29, 2025
1 check passed
@shubham1g5 shubham1g5 deleted the mergeNotificationsAndMessagingWorkers branch October 29, 2025 14:15
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.

5 participants