mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-02 12:06:53 +00:00
Use ProfileHelper.isPaymentAddressUpdateForbidden for both REST and gRPC
This commit is contained in:
1 parent
32befd7c9a
commit
d6c7c5e7bf
5 files changed
+38
-26
No files matched your search
+2
-8
@@ -181,14 +181,8 @@ public class ProfileController {
|
||||
final Optional<VersionedProfileV1> currentProfile =
|
||||
profilesManager.getV1(auth.accountIdentifier(), request.version());
|
||||
|
||||
if (request.paymentAddress() != null && request.paymentAddress().length != 0) {
|
||||
final boolean hasDisallowedPrefix =
|
||||
dynamicConfigurationManager.getConfiguration().getPaymentsConfiguration().getDisallowedPrefixes().stream()
|
||||
.anyMatch(prefix -> account.getNumber().startsWith(prefix));
|
||||
|
||||
if (hasDisallowedPrefix && currentProfile.map(VersionedProfileV1::paymentAddress).isEmpty()) {
|
||||
return Response.status(Response.Status.FORBIDDEN).build();
|
||||
}
|
||||
if (request.paymentAddress() != null && request.paymentAddress().length != 0 && ProfileHelper.isPaymentAddressUpdateForbidden(account, Optional.empty(), currentProfile, dynamicConfigurationManager)) {
|
||||
return Response.status(Response.Status.FORBIDDEN).build();
|
||||
}
|
||||
|
||||
final Optional<String> currentAvatar = ProfileHelper.getCurrentAvatar(currentProfile);
|
||||
|
||||
@@ -152,7 +152,7 @@ public class ProfileGrpcService extends SimpleProfileGrpc.ProfileImplBase {
|
||||
avatarData.finalAvatar().orElse(null),
|
||||
request.getV1Request().getAboutEmoji().toByteArray(),
|
||||
request.getV1Request().getAbout().toByteArray(),
|
||||
request.getPaymentAddress().toByteArray(),
|
||||
request.getPaymentAddress().isEmpty() ? null : request.getPaymentAddress().toByteArray(),
|
||||
request.getV1Request().getPhoneNumberSharing().toByteArray(),
|
||||
commitment);
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public class ProfileHelper {
|
||||
.getDisallowedPrefixes().stream()
|
||||
.anyMatch(prefix -> account.getNumber().startsWith(prefix));
|
||||
|
||||
return hasDisallowedPrefix && currentPaymentAddress.isEmpty();
|
||||
return hasDisallowedPrefix && currentPaymentAddress.filter(a -> a.length != 0).isEmpty();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in new issue
Block a user