mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-02 12:06:53 +00:00
Refine Profiles gRPC errors and documentation
This commit is contained in:
1 parent
90c27f6969
commit
12e265fb71
6 files changed
+119
-20
No files matched your search
@@ -72,7 +72,7 @@ public class ProfileGrpcHelper {
|
||||
} else {
|
||||
responseBuilder.setDataEtag(DataEtag.newBuilder()
|
||||
.setData(ByteString.copyFrom(p.data()))
|
||||
.setEtag(ByteString.copyFrom(p.dataHash()))
|
||||
.setEtagSha256(ByteString.copyFrom(p.dataHash()))
|
||||
.build());
|
||||
}
|
||||
});
|
||||
@@ -110,7 +110,7 @@ public class ProfileGrpcHelper {
|
||||
} else {
|
||||
responseBuilder.setPaymentAddressDataEtag(DataEtag.newBuilder()
|
||||
.setData(ByteString.copyFrom(paymentAddress.get()))
|
||||
.setEtag(ByteString.copyFrom(
|
||||
.setEtagSha256(ByteString.copyFrom(
|
||||
profile.map(VersionedProfile::paymentAddressHash).orElseGet(() -> hash(paymentAddress.get()))))
|
||||
.build());
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class ProfileGrpcService extends SimpleProfileGrpc.ProfileImplBase {
|
||||
: account.getCurrentProfileVersion().get().equals(expectedCurrentVersionHex);
|
||||
|
||||
if (!currentVersionMatchesExpected) {
|
||||
return SetProfileResponse.newBuilder().setWriteConflict(FailedPrecondition.newBuilder()
|
||||
return SetProfileResponse.newBuilder().setExpectedVersionWriteConflict(FailedPrecondition.newBuilder()
|
||||
.setDescription("current and expected profile versions must match")
|
||||
.build()).build();
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public class ProfileGrpcService extends SimpleProfileGrpc.ProfileImplBase {
|
||||
|
||||
} catch (WriteConflictException _) {
|
||||
return SetProfileResponse.newBuilder()
|
||||
.setWriteConflict(FailedPrecondition.newBuilder()
|
||||
.setExpectedDataWriteConflict(FailedPrecondition.newBuilder()
|
||||
.setDescription("current and expected data hash mismatch")
|
||||
.build())
|
||||
.build();
|
||||
@@ -189,7 +189,7 @@ public class ProfileGrpcService extends SimpleProfileGrpc.ProfileImplBase {
|
||||
|
||||
} catch (final WriteConflictException _) {
|
||||
return SetProfileResponse.newBuilder()
|
||||
.setWriteConflict(FailedPrecondition.newBuilder()
|
||||
.setExpectedVersionWriteConflict(FailedPrecondition.newBuilder()
|
||||
.setDescription("current and expected version mismatch")
|
||||
.build())
|
||||
.build();
|
||||
|
||||
@@ -104,6 +104,7 @@ public class ProfilesManager {
|
||||
/// Transactionally sets v1 and v2 Profile data in DynamoDB.
|
||||
///
|
||||
/// Note: writes to the Redis cache are not transactional, and a failed DynamoDB write may leave incorrect data in Redis
|
||||
/// @throws WriteConflictException if the expected data hash does not match the stored data hash
|
||||
public void set(UUID uuid, VersionedProfileV1 versionedProfileV1, VersionedProfile versionedProfile, @Nullable byte[] expectedCurrentDataHash) throws WriteConflictException {
|
||||
|
||||
final TransactWriteItem v1TransactWriteItem = profilesV1.getTransactWriteItem(uuid, versionedProfileV1);
|
||||
|
||||
Reference in new issue
Block a user