mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 02:18:08 +01:00
Only return payment address from latest profile (#408)
* Only return payment address from latest profile * Rename `currentVersionedProfile` to `currentProfileVersion` * Change return type to Optional * Update service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java Co-authored-by: Jon Chambers <63609320+jon-signal@users.noreply.github.com> * Fix broken test Co-authored-by: Jon Chambers <63609320+jon-signal@users.noreply.github.com>
This commit is contained in:
@@ -137,6 +137,7 @@ public class ProfileController {
|
||||
|
||||
account.setProfileName(request.getName());
|
||||
account.setAvatar(avatar);
|
||||
account.setCurrentProfileVersion(request.getVersion());
|
||||
accountsManager.update(account);
|
||||
|
||||
if (response.isPresent()) return Response.ok(response).build();
|
||||
@@ -202,7 +203,14 @@ public class ProfileController {
|
||||
String about = profile.map(VersionedProfile::getAbout).orElse(null);
|
||||
String aboutEmoji = profile.map(VersionedProfile::getAboutEmoji).orElse(null);
|
||||
String avatar = profile.map(VersionedProfile::getAvatar).orElse(accountProfile.get().getAvatar());
|
||||
String paymentAddress = profile.map(VersionedProfile::getPaymentAddress).orElse(null);
|
||||
Optional<String> currentProfileVersion = accountProfile.get().getCurrentProfileVersion();
|
||||
|
||||
// Allow requests where either the version matches the latest version on Account or the latest version on Account
|
||||
// is empty to read the payment address.
|
||||
final String paymentAddress = profile
|
||||
.filter(p -> currentProfileVersion.map(v -> v.equals(version)).orElse(true))
|
||||
.map(VersionedProfile::getPaymentAddress)
|
||||
.orElse(null);
|
||||
|
||||
Optional<ProfileKeyCredentialResponse> credential = getProfileCredential(credentialRequest, profile, uuid);
|
||||
|
||||
|
||||
@@ -31,6 +31,9 @@ public class Account implements Principal {
|
||||
@JsonProperty
|
||||
private String identityKey;
|
||||
|
||||
@JsonProperty("cpv")
|
||||
private String currentProfileVersion;
|
||||
|
||||
@JsonProperty
|
||||
private String name;
|
||||
|
||||
@@ -195,6 +198,14 @@ public class Account implements Principal {
|
||||
return lastSeen;
|
||||
}
|
||||
|
||||
public Optional<String> getCurrentProfileVersion() {
|
||||
return Optional.ofNullable(currentProfileVersion);
|
||||
}
|
||||
|
||||
public void setCurrentProfileVersion(String currentProfileVersion) {
|
||||
this.currentProfileVersion = currentProfileVersion;
|
||||
}
|
||||
|
||||
public String getProfileName() {
|
||||
return name;
|
||||
}
|
||||
@@ -267,5 +278,4 @@ public class Account implements Principal {
|
||||
public boolean implies(Subject subject) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user