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 CompletableFuture.completedFuture(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return messagesManager.mayHaveMessages(account.getIdentifier(IdentityType.ACI), device)
|
return messagesManager.mayHavePersistedMessages(account.getIdentifier(IdentityType.ACI), device)
|
||||||
.thenApply(mayHaveMessages -> !mayHaveMessages);
|
.thenApply(mayHavePersistedMessages -> !mayHavePersistedMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@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) {
|
public CompletableFuture<Boolean> mayHaveMessages(final UUID destinationUuid, final Device destinationDevice) {
|
||||||
return messagesCache.hasMessagesAsync(destinationUuid, destinationDevice.getId())
|
return messagesCache.hasMessagesAsync(destinationUuid, destinationDevice.getId())
|
||||||
.thenCombine(messagesDynamoDb.mayHaveMessages(destinationUuid, destinationDevice),
|
.thenCombine(messagesDynamoDb.mayHaveMessages(destinationUuid, destinationDevice),
|
||||||
|
|
|
@ -53,7 +53,7 @@ class NotifyIdleDevicesWithoutMessagesPushNotificationExperimentTest {
|
||||||
final boolean mayHaveMessages,
|
final boolean mayHaveMessages,
|
||||||
final boolean expectEligible) {
|
final boolean expectEligible) {
|
||||||
|
|
||||||
when(messagesManager.mayHaveMessages(account.getIdentifier(IdentityType.ACI), device))
|
when(messagesManager.mayHavePersistedMessages(account.getIdentifier(IdentityType.ACI), device))
|
||||||
.thenReturn(CompletableFuture.completedFuture(mayHaveMessages));
|
.thenReturn(CompletableFuture.completedFuture(mayHaveMessages));
|
||||||
|
|
||||||
when(idleDeviceNotificationScheduler.isIdle(device)).thenReturn(isDeviceIdle);
|
when(idleDeviceNotificationScheduler.isIdle(device)).thenReturn(isDeviceIdle);
|
||||||
|
|
Loading…
Reference in New Issue