Skip to content

Conversation

@irfano
Copy link
Contributor

@irfano irfano commented Jan 21, 2026

Closes WOOMOB-1957

Description

This PR adds deduplication logic to NotificationMessageHandler to prevent duplicate push notifications. When WOO_PUSH_NOTIFICATIONS_SYSTEM feature flag is enabled, we check if the incoming notification is from WPCOM (note_id > 0) and if the device is already registered with Woo Core (hasPushToken()). If both conditions are true, we skip the WPCOM notification since the same event will also arrive via Woo Core.

Test Steps

  1. Set up a store with the new Woo Core endpoints by following these steps: p91TBi-dyW-p2#comment-14564
  2. Install the app and log into your store.
  3. Submit a product review from the web interface.
  4. Regression: Confirm you receive the notification, because the feature flag is disabled.
  5. Apply this patch to enable the feature flag: Enable_WOO_PUSH_NOTIFICATIONS_SYSTEM_feature_flag_for_debug_builds.patch
  6. Rebuild the app.
  7. Logout and log in again the app to trigger new push token registration. (you may need to kill and restart after login)
  8. Submit another product review.
  9. Verify that you do not receive a notification. (Note: You won't receive it yet because the development plugin is still a work in progress.)

Images/gif

  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

@irfano irfano added this to the 24.0 milestone Jan 21, 2026
@irfano irfano requested a review from JorgeMucientes January 21, 2026 00:07
@irfano irfano added feature: notifications Related to notifications or notifs. Task (new) labels Jan 21, 2026
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 21, 2026

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App NameWooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit8a42fa9
Direct Downloadwoocommerce-wear-prototype-build-pr15222-8a42fa9.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 21, 2026

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit8a42fa9
Direct Downloadwoocommerce-prototype-build-pr15222-8a42fa9.apk

@codecov-commenter
Copy link

codecov-commenter commented Jan 21, 2026

Codecov Report

❌ Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.70%. Comparing base (2168065) to head (8a42fa9).

Files with missing lines Patch % Lines
...d/notifications/push/NotificationMessageHandler.kt 70.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@                                 Coverage Diff                                  @@
##             issue/woomob-2042-add-fallback-to-wpcom-pn-system   #15222   +/-   ##
====================================================================================
  Coverage                                                38.70%   38.70%           
- Complexity                                               10559    10562    +3     
====================================================================================
  Files                                                     2194     2194           
  Lines                                                   124978   124985    +7     
  Branches                                                 17302    17305    +3     
====================================================================================
+ Hits                                                     48372    48380    +8     
+ Misses                                                   71709    71708    -1     
  Partials                                                  4897     4897           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JorgeMucientes JorgeMucientes self-assigned this Jan 21, 2026
@JorgeMucientes
Copy link
Contributor

JorgeMucientes commented Jan 22, 2026

Hey @irfano the code changes look good, however, I think we can do this in a cleaner way once we merge the changes from the PR I'll open tomorrow early morning (I'm wrapping up testing changes): #15238.
With the changes from that PR we can directly use PushNotificationRegistrationStatus class to verify if the user is registered in Woo system. That will avoid having to change the code you added here once we remove the feature flag. In fact relying on PushNotificationRegistrationStatus use case is feature flag agnostic,
Let me know what you think.

@irfano irfano modified the milestones: 24.0, 24.1 Jan 22, 2026
…system

- Bypass user ID and `remoteNoteId` validation checks when `WOO_PUSH_NOTIFICATIONS_SYSTEM` feature flag is enabled.
- Skip WPCOM notifications when the app is registered with Woo Core to avoid duplicates.
@irfano irfano force-pushed the issue/WOOMOB-1957-update-how-decide-whether-accept-pn branch from 823bd27 to 8a42fa9 Compare January 22, 2026 20:44
@irfano irfano changed the base branch from trunk to issue/woomob-2042-add-fallback-to-wpcom-pn-system January 22, 2026 20:44
@irfano irfano marked this pull request as draft January 22, 2026 20:45
@irfano
Copy link
Contributor Author

irfano commented Jan 22, 2026

I've rebased onto your branch. Let's merge yours first since this is smaller. I agree that using PushNotificationRegistrationStatus in this PR is cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: notifications Related to notifications or notifs. Task (new)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants