From 4485e26562ee1070b81081a31d1368de9b05b183 Mon Sep 17 00:00:00 2001 From: Ravi Khadiwala Date: Fri, 8 May 2026 13:39:36 -0500 Subject: [PATCH] rename maxUploadSizeInBytes to maxAttachmentUploadSizeInBytes --- service/config/sample.yml | 2 +- .../textsecuregcm/WhisperServerService.java | 8 ++++---- .../configuration/AttachmentsConfiguration.java | 2 +- .../grpc/BackupsAnonymousGrpcService.java | 2 +- .../grpc/BackupsAnonymousGrpcServiceTest.java | 14 ++++++++------ service/src/test/resources/config/test.yml | 2 +- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/service/config/sample.yml b/service/config/sample.yml index 0737f337e..10818ef58 100644 --- a/service/config/sample.yml +++ b/service/config/sample.yml @@ -234,7 +234,7 @@ messageCache: # Redis server configuration for message store cache configurationUri: redis://redis.example.com:6379/ attachments: - maxUploadSizeInBytes: 1024 + maxAttachmentUploadSizeInBytes: 1024 maxMessageBackupUploadSizeInBytes: 1024 gcpAttachments: # GCP Storage configuration diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java index d00ab0d53..536e8271a 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java @@ -977,7 +977,7 @@ public class WhisperServerService extends Application ServerInterceptors.intercept(bindableService, // Note: interceptors run in the reverse order they are added; the remote deprecation filter // depends on the user-agent context so it has to come first here! @@ -997,7 +997,7 @@ public class WhisperServerService extends Application ServerInterceptors.intercept(bindableService, // Note: interceptors run in the reverse order they are added; the remote deprecation filter @@ -1103,8 +1103,8 @@ public class WhisperServerService extends Application uploadLength > maxAttachmentSize; case MESSAGES -> { backupMetrics.updateMessageBackupSizeDistribution(backupUser, uploadLength > maxMessageBackupSize, Optional.of(uploadLength)); - yield uploadLength > maxAttachmentSize; + yield uploadLength > maxMessageBackupSize; } case UPLOADTYPE_NOT_SET -> throw GrpcExceptions.fieldViolation("upload_type", "Must set upload_type"); }; diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/BackupsAnonymousGrpcServiceTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/BackupsAnonymousGrpcServiceTest.java index bef6678b6..8abbdfcdf 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/BackupsAnonymousGrpcServiceTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/BackupsAnonymousGrpcServiceTest.java @@ -346,25 +346,27 @@ class BackupsAnonymousGrpcServiceTest extends @EnumSource(value = GetUploadFormRequest.UploadTypeCase.class, names = "UPLOADTYPE_NOT_SET", mode = EnumSource.Mode.EXCLUDE) public void uploadForm(GetUploadFormRequest.UploadTypeCase uploadType) throws BackupException, RateLimitExceededException { - final long uploadLength = 100; final BackupUploadDescriptor result = new BackupUploadDescriptor(3, "abc", Map.of("k", "v"), "example.org"); final GetUploadFormRequest.Builder builder = switch (uploadType) { case MESSAGES -> { - when(backupManager.createMessageBackupUploadDescriptor(any(), eq(uploadLength))) + when(backupManager.createMessageBackupUploadDescriptor(any(), eq(MAX_MESSAGE_BACKUP_OBJECT_SIZE))) .thenReturn(result); - yield GetUploadFormRequest.newBuilder().setMessages(GetUploadFormRequest.MessagesUploadType.getDefaultInstance()); + yield GetUploadFormRequest.newBuilder() + .setMessages(GetUploadFormRequest.MessagesUploadType.getDefaultInstance()) + .setUploadLength(MAX_MESSAGE_BACKUP_OBJECT_SIZE); } case MEDIA -> { - when(backupManager.createTemporaryAttachmentUploadDescriptor(any(), eq(uploadLength))) + when(backupManager.createTemporaryAttachmentUploadDescriptor(any(), eq(MAX_ATTACHMENT_OBJECT_SIZE))) .thenReturn(result); - yield GetUploadFormRequest.newBuilder().setMedia(GetUploadFormRequest.MediaUploadType.getDefaultInstance()); + yield GetUploadFormRequest.newBuilder() + .setMedia(GetUploadFormRequest.MediaUploadType.getDefaultInstance()) + .setUploadLength(MAX_ATTACHMENT_OBJECT_SIZE); } default -> throw new IllegalArgumentException("Unknown upload type: " + uploadType); }; final GetUploadFormRequest request = builder .setSignedPresentation(signedPresentation(presentation)) - .setUploadLength(uploadLength) .build(); final GetUploadFormResponse response = unauthenticatedServiceStub().getUploadForm(request); assertThat(response.getUploadForm().getCdn()).isEqualTo(3); diff --git a/service/src/test/resources/config/test.yml b/service/src/test/resources/config/test.yml index fcdecd10f..9fb5328bd 100644 --- a/service/src/test/resources/config/test.yml +++ b/service/src/test/resources/config/test.yml @@ -242,7 +242,7 @@ messageCache: # Redis server configuration for message store cache type: local attachments: - maxUploadSizeInBytes: 1024 + maxAttachmentUploadSizeInBytes: 1024 maxMessageBackupUploadSizeInBytes: 1024 gcpAttachments: # GCP Storage configuration