Add a method to check for the presence of persisted messages, skipping the cache
This commit is contained in:
parent
f1c153f39f
commit
822092044b
|
@ -64,8 +64,8 @@ public class NotifyIdleDevicesWithoutMessagesPushNotificationExperiment implemen
|
|||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
|
||||
return messagesManager.mayHaveMessages(account.getIdentifier(IdentityType.ACI), device)
|
||||
.thenApply(mayHaveMessages -> !mayHaveMessages);
|
||||
return messagesManager.mayHavePersistedMessages(account.getIdentifier(IdentityType.ACI), device)
|
||||
.thenApply(mayHavePersistedMessages -> !mayHavePersistedMessages);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
|
|
@ -67,6 +67,10 @@ public class MessagesManager {
|
|||
}
|
||||
}
|
||||
|
||||
public CompletableFuture<Boolean> mayHavePersistedMessages(final UUID destinationUuid, final Device destinationDevice) {
|
||||
return messagesDynamoDb.mayHaveMessages(destinationUuid, destinationDevice);
|
||||
}
|
||||
|
||||
public CompletableFuture<Boolean> mayHaveMessages(final UUID destinationUuid, final Device destinationDevice) {
|
||||
return messagesCache.hasMessagesAsync(destinationUuid, destinationDevice.getId())
|
||||
.thenCombine(messagesDynamoDb.mayHaveMessages(destinationUuid, destinationDevice),
|
||||
|
|
|
@ -53,7 +53,7 @@ class NotifyIdleDevicesWithoutMessagesPushNotificationExperimentTest {
|
|||
final boolean mayHaveMessages,
|
||||
final boolean expectEligible) {
|
||||
|
||||
when(messagesManager.mayHaveMessages(account.getIdentifier(IdentityType.ACI), device))
|
||||
when(messagesManager.mayHavePersistedMessages(account.getIdentifier(IdentityType.ACI), device))
|
||||
.thenReturn(CompletableFuture.completedFuture(mayHaveMessages));
|
||||
|
||||
when(idleDeviceNotificationScheduler.isIdle(device)).thenReturn(isDeviceIdle);
|
||||
|
|
Loading…
Reference in New Issue