mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 07:28:06 +01:00
Support for GV2 capability flag
This commit is contained in:
@@ -5,7 +5,6 @@ import com.codahale.metrics.annotation.Timed;
|
||||
import org.apache.commons.codec.DecoderException;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.valuehandling.UnwrapValidatedValue;
|
||||
import org.signal.zkgroup.InvalidInputException;
|
||||
import org.signal.zkgroup.VerificationFailedException;
|
||||
@@ -30,8 +29,8 @@ import org.whispersystems.textsecuregcm.storage.Account;
|
||||
import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
||||
import org.whispersystems.textsecuregcm.storage.ProfilesManager;
|
||||
import org.whispersystems.textsecuregcm.storage.UsernamesManager;
|
||||
import org.whispersystems.textsecuregcm.util.ExactlySize;
|
||||
import org.whispersystems.textsecuregcm.storage.VersionedProfile;
|
||||
import org.whispersystems.textsecuregcm.util.ExactlySize;
|
||||
import org.whispersystems.textsecuregcm.util.Pair;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@@ -199,7 +198,7 @@ public class ProfileController {
|
||||
accountProfile.get().getIdentityKey(),
|
||||
UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()),
|
||||
accountProfile.get().isUnrestrictedUnidentifiedAccess(),
|
||||
new UserCapabilities(accountProfile.get().isUuidAddressingSupported()),
|
||||
new UserCapabilities(accountProfile.get().isUuidAddressingSupported(), accountProfile.get().isGroupsV2Supported()),
|
||||
username.orElse(null),
|
||||
null, credential.orElse(null)));
|
||||
} catch (InvalidInputException e) {
|
||||
@@ -235,7 +234,7 @@ public class ProfileController {
|
||||
accountProfile.get().getIdentityKey(),
|
||||
UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()),
|
||||
accountProfile.get().isUnrestrictedUnidentifiedAccess(),
|
||||
new UserCapabilities(accountProfile.get().isUuidAddressingSupported()),
|
||||
new UserCapabilities(accountProfile.get().isUuidAddressingSupported(), accountProfile.get().isGroupsV2Supported()),
|
||||
username,
|
||||
accountProfile.get().getUuid(), null);
|
||||
}
|
||||
@@ -306,7 +305,7 @@ public class ProfileController {
|
||||
accountProfile.get().getIdentityKey(),
|
||||
UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()),
|
||||
accountProfile.get().isUnrestrictedUnidentifiedAccess(),
|
||||
new UserCapabilities(accountProfile.get().isUuidAddressingSupported()),
|
||||
new UserCapabilities(accountProfile.get().isUuidAddressingSupported(), accountProfile.get().isGroupsV2Supported()),
|
||||
username.orElse(null),
|
||||
null, null);
|
||||
}
|
||||
|
||||
@@ -6,13 +6,21 @@ public class UserCapabilities {
|
||||
@JsonProperty
|
||||
private boolean uuid;
|
||||
|
||||
@JsonProperty
|
||||
private boolean gv2;
|
||||
|
||||
public UserCapabilities() {}
|
||||
|
||||
public UserCapabilities(boolean uuid) {
|
||||
public UserCapabilities(boolean uuid, boolean gv2) {
|
||||
this.uuid = uuid;
|
||||
this.gv2 = gv2;
|
||||
}
|
||||
|
||||
public boolean isUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public boolean isGv2() {
|
||||
return gv2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +138,12 @@ public class Account implements Principal {
|
||||
.allMatch(device -> device.getCapabilities() != null && device.getCapabilities().isUuid());
|
||||
}
|
||||
|
||||
public boolean isGroupsV2Supported() {
|
||||
return devices.stream()
|
||||
.filter(Device::isEnabled)
|
||||
.allMatch(device -> device.getCapabilities() != null && device.getCapabilities().isGv2());
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return
|
||||
getMasterDevice().isPresent() &&
|
||||
|
||||
@@ -270,15 +270,23 @@ public class Device {
|
||||
@JsonProperty
|
||||
private boolean uuid;
|
||||
|
||||
@JsonProperty
|
||||
private boolean gv2;
|
||||
|
||||
public DeviceCapabilities() {}
|
||||
|
||||
public DeviceCapabilities(boolean uuid) {
|
||||
public DeviceCapabilities(boolean uuid, boolean gv2) {
|
||||
this.uuid = uuid;
|
||||
this.gv2 = gv2;
|
||||
}
|
||||
|
||||
public boolean isUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public boolean isGv2() {
|
||||
return gv2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user