Commit 6dc536e
authored
fix: link existing push token when notification accounts are added (#8449)
## Explanation
**Summary**
When notification accounts are added after push notifications have
already been enabled, we were updating on-chain triggers, but not
re-linking the existing Firebase token to the newly added addresses. As
a result, the backend never received the additive `POST /api/v2/token`
call for those new (address, token) pairs.
This change adds a dedicated additive push-link path that reuses the
current `fcmToken` and links only the newly added
addresses, without rotating the token or sending oldToken.
Because notification account discovery already includes all keyrings,
this now covers:
- adding accounts on the primary SRP
- adding accounts on imported/subsequent SRPs
**Code Changes**
- Add NotificationServicesPushController:addPushNotificationLinks
- Use the existing fcmToken to POST newly added addresses to the push
registration endpoint
- Call that new method from
NotificationServicesController.enableAccounts(...) after on-chain
notifications are enabled
- Add focused tests for both the controller flow and the push-controller
API call
- Update the package changelog
<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:
* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->
## References
<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?
For example:
* Fixes #12345
* Related to #67890
-->
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Updates push-notification registration flow to add backend token links
when accounts are enabled, affecting server-side delivery for newly
added addresses. Risk is moderate due to changes in notification
subscription side effects and new messenger action surface, but behavior
is guarded and tested.
>
> **Overview**
> Fixes a gap where enabling notifications for newly added accounts
updated on-chain triggers but **did not register the existing device
push token** for those addresses.
>
> Adds `NotificationServicesPushController:addPushNotificationLinks`
(with exported action type) to POST additive `(address, token)` links
using the current `fcmToken`, and wires
`NotificationServicesController.enableAccounts()` to invoke it after
enabling on-chain notifications (silent-fail like other push calls).
Tests are updated to cover the new controller call and the
push-controller API call/guard conditions, and the changelog documents
the fix.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
7a8eae8. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 2311c16 commit 6dc536e
File tree
7 files changed
+157
-1
lines changed- packages/notification-services-controller
- src
- NotificationServicesController
- NotificationServicesPushController
7 files changed
+157
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
Lines changed: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
819 | 820 | | |
820 | 821 | | |
821 | 822 | | |
822 | | - | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
823 | 828 | | |
824 | 829 | | |
825 | 830 | | |
| |||
828 | 833 | | |
829 | 834 | | |
830 | 835 | | |
| 836 | + | |
831 | 837 | | |
832 | 838 | | |
833 | 839 | | |
| |||
1712 | 1718 | | |
1713 | 1719 | | |
1714 | 1720 | | |
| 1721 | + | |
1715 | 1722 | | |
1716 | 1723 | | |
1717 | 1724 | | |
| |||
1737 | 1744 | | |
1738 | 1745 | | |
1739 | 1746 | | |
| 1747 | + | |
1740 | 1748 | | |
1741 | 1749 | | |
1742 | 1750 | | |
| |||
1766 | 1774 | | |
1767 | 1775 | | |
1768 | 1776 | | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
1769 | 1782 | | |
1770 | 1783 | | |
1771 | 1784 | | |
| |||
1815 | 1828 | | |
1816 | 1829 | | |
1817 | 1830 | | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
1818 | 1838 | | |
1819 | 1839 | | |
1820 | 1840 | | |
| |||
1854 | 1874 | | |
1855 | 1875 | | |
1856 | 1876 | | |
| 1877 | + | |
1857 | 1878 | | |
1858 | 1879 | | |
1859 | 1880 | | |
| |||
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
345 | 355 | | |
346 | 356 | | |
347 | 357 | | |
| |||
983 | 993 | | |
984 | 994 | | |
985 | 995 | | |
| 996 | + | |
| 997 | + | |
986 | 998 | | |
987 | 999 | | |
988 | 1000 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
38 | 51 | | |
39 | 52 | | |
40 | 53 | | |
| |||
70 | 83 | | |
71 | 84 | | |
72 | 85 | | |
| 86 | + | |
73 | 87 | | |
74 | 88 | | |
Lines changed: 67 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
| |||
347 | 353 | | |
348 | 354 | | |
349 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
350 | 417 | | |
351 | 418 | | |
352 | 419 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
357 | 359 | | |
358 | 360 | | |
359 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
360 | 396 | | |
361 | 397 | | |
362 | 398 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
0 commit comments