mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 05:08:03 +01:00
Assume all accounts have primary devices
This commit is contained in:
committed by
Jon Chambers
parent
69990c23a5
commit
00e72a30c9
@@ -45,7 +45,7 @@ public class PushChallengeManager {
|
||||
}
|
||||
|
||||
public void sendChallenge(final Account account) throws NotPushRegisteredException {
|
||||
final Device primaryDevice = account.getPrimaryDevice().orElseThrow(NotPushRegisteredException::new);
|
||||
final Device primaryDevice = account.getPrimaryDevice();
|
||||
|
||||
final byte[] token = new byte[CHALLENGE_TOKEN_LENGTH];
|
||||
random.nextBytes(token);
|
||||
@@ -86,16 +86,15 @@ public class PushChallengeManager {
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
}
|
||||
|
||||
final String platform = account.getPrimaryDevice().map(primaryDevice -> {
|
||||
if (StringUtils.isNotBlank(primaryDevice.getGcmId())) {
|
||||
return ClientPlatform.ANDROID.name().toLowerCase();
|
||||
} else if (StringUtils.isNotBlank(primaryDevice.getApnId())) {
|
||||
return ClientPlatform.IOS.name().toLowerCase();
|
||||
} else {
|
||||
return "unknown";
|
||||
}
|
||||
}).orElse("unknown");
|
||||
final String platform;
|
||||
|
||||
if (StringUtils.isNotBlank(account.getPrimaryDevice().getGcmId())) {
|
||||
platform = ClientPlatform.ANDROID.name().toLowerCase();
|
||||
} else if (StringUtils.isNotBlank(account.getPrimaryDevice().getApnId())) {
|
||||
platform = ClientPlatform.IOS.name().toLowerCase();
|
||||
} else {
|
||||
platform = "unknown";
|
||||
}
|
||||
|
||||
Metrics.counter(CHALLENGE_ANSWERED_COUNTER_NAME,
|
||||
PLATFORM_TAG_NAME, platform,
|
||||
|
||||
Reference in New Issue
Block a user