mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 17:38:04 +01:00
Retire Device#hasMessageDeliveryChannel()
This commit is contained in:
committed by
Jon Chambers
parent
1a09f5807b
commit
73e0aea85c
@@ -14,7 +14,6 @@ import java.util.OptionalInt;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
import javax.annotation.Nullable;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.whispersystems.textsecuregcm.auth.SaltedTokenHash;
|
||||
import org.whispersystems.textsecuregcm.util.DeviceNameByteArrayAdapter;
|
||||
|
||||
@@ -187,10 +186,6 @@ public class Device {
|
||||
this.capabilities = capabilities;
|
||||
}
|
||||
|
||||
public boolean hasMessageDeliveryChannel() {
|
||||
return fetchesMessages || StringUtils.isNotEmpty(getApnId()) || StringUtils.isNotEmpty(getGcmId());
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
return isPrimary()
|
||||
? lastSeen < (System.currentTimeMillis() - ALLOWED_PRIMARY_IDLE_MILLIS)
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration;
|
||||
@@ -245,7 +246,7 @@ public class MessagePersister implements Managed {
|
||||
// its messages) is unlinked
|
||||
final Device deviceToDelete = account.getDevices()
|
||||
.stream()
|
||||
.filter(d -> !d.isPrimary() && !d.hasMessageDeliveryChannel())
|
||||
.filter(d -> !d.isPrimary() && !deviceHasMessageDeliveryChannel(d))
|
||||
.min(Comparator.comparing(Device::getLastSeen))
|
||||
.or(() ->
|
||||
Flux.fromIterable(account.getDevices())
|
||||
@@ -288,4 +289,8 @@ public class MessagePersister implements Managed {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean deviceHasMessageDeliveryChannel(final Device device) {
|
||||
return device.getFetchesMessages() || StringUtils.isNotEmpty(device.getApnId()) || StringUtils.isNotEmpty(device.getGcmId());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user