mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-01 09:06:47 +00:00
Add a method to check for the presence of persisted messages, skipping the cache
This commit is contained in:
1 parent
f1c153f39f
commit
5e0eef7b3d
3 files changed
+7
-3
No files matched your search
+2
-2
@@ -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),
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user