File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -236,6 +236,15 @@ class WakeNodeWorker @AssistedInject constructor(
236236 return
237237 }
238238
239+ // The in-app UI or foreground service owns this event: it records the activity (via the same
240+ // insertActivityFromCjit dedup) and shows the richer notification/sheet. Defer entirely —
241+ // do NOT insert here, or we'd win the dedup race and silence the in-process handler.
242+ if (isHandledInProcess()) {
243+ Logger .debug(" Skipping CJIT notification: handled in-process" , context = TAG )
244+ bestAttemptContent = null
245+ return
246+ }
247+
239248 // A duplicate channel ready event for an already recorded CJIT receive must not notify again
240249 val inserted = activityRepo.insertActivityFromCjit(cjitEntry = cjitEntry, channel = channel)
241250 .getOrDefault(false )
@@ -255,13 +264,6 @@ class WakeNodeWorker @AssistedInject constructor(
255264 )
256265 )
257266
258- // The in-app UI or foreground service shows a richer notification for this event; avoid duplicating it
259- if (isHandledInProcess()) {
260- Logger .debug(" Skipping CJIT notification: handled in-process" , context = TAG )
261- bestAttemptContent = null
262- return
263- }
264-
265267 bestAttemptContent = receivedNotificationContent.build(sats.toLong())
266268 }
267269
Original file line number Diff line number Diff line change @@ -123,8 +123,9 @@ class WakeNodeWorkerTest : BaseUnitTest() {
123123
124124 assertEquals(ListenableWorker .Result .success(), result)
125125 assertNull(findNotificationByTitle(receivedTitle), " Deduped when the foreground service handles it" )
126- // Activity is still recorded so the receive is not lost
127- verify(activityRepo).insertActivityFromCjit(any(), any())
126+ // Defers entirely: the in-process handler owns the insert, so the worker must not win the dedup race
127+ verify(activityRepo, never()).insertActivityFromCjit(any(), any())
128+ verify(cacheStore, never()).setBackgroundReceive(any())
128129 }
129130
130131 @Test
@@ -152,7 +153,9 @@ class WakeNodeWorkerTest : BaseUnitTest() {
152153
153154 assertEquals(ListenableWorker .Result .success(), result)
154155 assertNull(findNotificationByTitle(receivedTitle), " Notification is deduped when the in-app UI handles it" )
155- verify(activityRepo).insertActivityFromCjit(any(), any())
156+ // Defers entirely: the in-app handler owns the insert, so the worker must not win the dedup race
157+ verify(activityRepo, never()).insertActivityFromCjit(any(), any())
158+ verify(cacheStore, never()).setBackgroundReceive(any())
156159 }
157160
158161 @Test
You can’t perform that action at this time.
0 commit comments