Refactor repeated use of the UserCapabilities constructor
This commit is contained in:
parent
bfd2c32d4e
commit
57ff9f86f5
|
@ -231,10 +231,6 @@ public class ProfileController {
|
||||||
|
|
||||||
Optional<ProfileKeyCredentialResponse> credential = getProfileCredential(credentialRequest, profile, uuid);
|
Optional<ProfileKeyCredentialResponse> credential = getProfileCredential(credentialRequest, profile, uuid);
|
||||||
|
|
||||||
final UserCapabilities userCapabilities = new UserCapabilities(
|
|
||||||
accountProfile.get().isGroupsV2Supported(),
|
|
||||||
accountProfile.get().isGv1MigrationSupported(),
|
|
||||||
accountProfile.get().isSenderKeySupported());
|
|
||||||
return Optional.of(new Profile(name,
|
return Optional.of(new Profile(name,
|
||||||
about,
|
about,
|
||||||
aboutEmoji,
|
aboutEmoji,
|
||||||
|
@ -243,7 +239,7 @@ public class ProfileController {
|
||||||
accountProfile.get().getIdentityKey(),
|
accountProfile.get().getIdentityKey(),
|
||||||
UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()),
|
UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()),
|
||||||
accountProfile.get().isUnrestrictedUnidentifiedAccess(),
|
accountProfile.get().isUnrestrictedUnidentifiedAccess(),
|
||||||
userCapabilities,
|
UserCapabilities.createForAccount(accountProfile.get()),
|
||||||
username.orElse(null),
|
username.orElse(null),
|
||||||
null,
|
null,
|
||||||
credential.orElse(null)));
|
credential.orElse(null)));
|
||||||
|
@ -275,10 +271,6 @@ public class ProfileController {
|
||||||
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
|
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
final UserCapabilities userCapabilities = new UserCapabilities(
|
|
||||||
accountProfile.get().isGroupsV2Supported(),
|
|
||||||
accountProfile.get().isGv1MigrationSupported(),
|
|
||||||
accountProfile.get().isSenderKeySupported());
|
|
||||||
return new Profile(accountProfile.get().getProfileName(),
|
return new Profile(accountProfile.get().getProfileName(),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
@ -287,7 +279,7 @@ public class ProfileController {
|
||||||
accountProfile.get().getIdentityKey(),
|
accountProfile.get().getIdentityKey(),
|
||||||
UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()),
|
UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()),
|
||||||
accountProfile.get().isUnrestrictedUnidentifiedAccess(),
|
accountProfile.get().isUnrestrictedUnidentifiedAccess(),
|
||||||
userCapabilities,
|
UserCapabilities.createForAccount(accountProfile.get()),
|
||||||
username,
|
username,
|
||||||
accountProfile.get().getUuid(),
|
accountProfile.get().getUuid(),
|
||||||
null);
|
null);
|
||||||
|
@ -354,10 +346,6 @@ public class ProfileController {
|
||||||
username = usernamesManager.get(accountProfile.get().getUuid());
|
username = usernamesManager.get(accountProfile.get().getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
final UserCapabilities userCapabilities = new UserCapabilities(
|
|
||||||
accountProfile.get().isGroupsV2Supported(),
|
|
||||||
accountProfile.get().isGv1MigrationSupported(),
|
|
||||||
accountProfile.get().isSenderKeySupported());
|
|
||||||
return new Profile(accountProfile.get().getProfileName(),
|
return new Profile(accountProfile.get().getProfileName(),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
@ -366,7 +354,7 @@ public class ProfileController {
|
||||||
accountProfile.get().getIdentityKey(),
|
accountProfile.get().getIdentityKey(),
|
||||||
UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()),
|
UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()),
|
||||||
accountProfile.get().isUnrestrictedUnidentifiedAccess(),
|
accountProfile.get().isUnrestrictedUnidentifiedAccess(),
|
||||||
userCapabilities,
|
UserCapabilities.createForAccount(accountProfile.get()),
|
||||||
username.orElse(null),
|
username.orElse(null),
|
||||||
null,
|
null,
|
||||||
null);
|
null);
|
||||||
|
|
|
@ -6,8 +6,17 @@
|
||||||
package org.whispersystems.textsecuregcm.entities;
|
package org.whispersystems.textsecuregcm.entities;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import org.whispersystems.textsecuregcm.storage.Account;
|
||||||
|
|
||||||
public class UserCapabilities {
|
public class UserCapabilities {
|
||||||
|
|
||||||
|
public static UserCapabilities createForAccount(Account account) {
|
||||||
|
return new UserCapabilities(
|
||||||
|
account.isGroupsV2Supported(),
|
||||||
|
account.isGv1MigrationSupported(),
|
||||||
|
account.isSenderKeySupported());
|
||||||
|
}
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private boolean gv2;
|
private boolean gv2;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue