rename maxUploadSizeInBytes to maxAttachmentUploadSizeInBytes
This commit is contained in:
parent
05b7a140fc
commit
4485e26562
@ -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
|
||||
|
||||
@ -977,7 +977,7 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
||||
new BackupsGrpcService(accountsManager, backupAuthManager, backupMetrics),
|
||||
new DevicesGrpcService(accountsManager),
|
||||
new AttachmentsGrpcService(experimentEnrollmentManager, rateLimiters,
|
||||
gcsAttachmentGenerator, tusAttachmentGenerator, config.getAttachments().maxUploadSizeInBytes()))
|
||||
gcsAttachmentGenerator, tusAttachmentGenerator, config.getAttachments().maxAttachmentUploadSizeInBytes()))
|
||||
.map(bindableService -> 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<WhisperServerConfiguration
|
||||
new ProfileAnonymousGrpcService(accountsManager, profilesManager, profileBadgeConverter, zkSecretParams),
|
||||
new PaymentsGrpcService(currencyManager),
|
||||
new MessagesAnonymousGrpcService(accountsManager, rateLimiters, messageSender, groupSendTokenUtil, messageByteLimitCardinalityEstimator, spamChecker, Clock.systemUTC()),
|
||||
new BackupsAnonymousGrpcService(backupManager, backupMetrics, config.getAttachments().maxUploadSizeInBytes(), config.getAttachments().maxMessageBackupUploadSizeInBytes()),
|
||||
new BackupsAnonymousGrpcService(backupManager, backupMetrics, config.getAttachments().maxAttachmentUploadSizeInBytes(), config.getAttachments().maxMessageBackupUploadSizeInBytes()),
|
||||
ExternalServiceCredentialsAnonymousGrpcService.create(accountsManager, config))
|
||||
.map(bindableService -> 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<WhisperServerConfiguration
|
||||
usernameHashZkProofVerifier),
|
||||
new AccountControllerV2(accountsManager, changeNumberManager),
|
||||
new AttachmentControllerV4(rateLimiters, gcsAttachmentGenerator, tusAttachmentGenerator,
|
||||
experimentEnrollmentManager, config.getAttachments().maxUploadSizeInBytes()),
|
||||
new ArchiveController(accountsManager, backupAuthManager, backupManager, backupMetrics, config.getAttachments().maxUploadSizeInBytes(), config.getAttachments().maxMessageBackupUploadSizeInBytes()),
|
||||
experimentEnrollmentManager, config.getAttachments().maxAttachmentUploadSizeInBytes()),
|
||||
new ArchiveController(accountsManager, backupAuthManager, backupManager, backupMetrics, config.getAttachments().maxAttachmentUploadSizeInBytes(), config.getAttachments().maxMessageBackupUploadSizeInBytes()),
|
||||
new CallRoutingControllerV2(rateLimiters, cloudflareTurnCredentialsManager),
|
||||
new CallLinkController(rateLimiters, callingGenericZkSecretParams),
|
||||
new CallQualitySurveyController(callQualitySurveyManager),
|
||||
|
||||
@ -7,6 +7,6 @@ package org.whispersystems.textsecuregcm.configuration;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
|
||||
public record AttachmentsConfiguration(
|
||||
@Positive long maxUploadSizeInBytes,
|
||||
@Positive long maxAttachmentUploadSizeInBytes,
|
||||
@Positive long maxMessageBackupUploadSizeInBytes) {
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ public class BackupsAnonymousGrpcService extends SimpleBackupsAnonymousGrpc.Back
|
||||
case MEDIA -> 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");
|
||||
};
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user