mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-19 14:38:04 +01:00
Revert "Include client version in the large message counter tags"
This reverts commit 3ac7a41f9b.
This commit is contained in:
committed by
Jon Chambers
parent
fecb032d8f
commit
7fd0cb32f6
@@ -722,7 +722,7 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
||||
|
||||
final AccountAuthenticator accountAuthenticator = new AccountAuthenticator(accountsManager);
|
||||
|
||||
final MessageSender messageSender = new MessageSender(messagesManager, pushNotificationManager, clientReleaseManager);
|
||||
final MessageSender messageSender = new MessageSender(messagesManager, pushNotificationManager);
|
||||
final ReceiptSender receiptSender = new ReceiptSender(accountsManager, messageSender, receiptSenderExecutor);
|
||||
final CloudflareTurnCredentialsManager cloudflareTurnCredentialsManager = new CloudflareTurnCredentialsManager(
|
||||
config.getTurnConfiguration().cloudflare().apiToken().value(),
|
||||
@@ -748,7 +748,7 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
||||
PushChallengeManager pushChallengeManager = new PushChallengeManager(pushNotificationManager,
|
||||
pushChallengeDynamoDb);
|
||||
|
||||
ChangeNumberManager changeNumberManager = new ChangeNumberManager(messageSender, accountsManager, clientReleaseManager, Clock.systemUTC());
|
||||
ChangeNumberManager changeNumberManager = new ChangeNumberManager(messageSender, accountsManager, Clock.systemUTC());
|
||||
|
||||
HttpClient currencyClient = HttpClient.newBuilder().version(HttpClient.Version.HTTP_2).connectTimeout(Duration.ofSeconds(10)).build();
|
||||
FixerClient fixerClient = config.getPaymentsServiceConfiguration().externalClients()
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.whispersystems.textsecuregcm.identity.ServiceIdentifier;
|
||||
import org.whispersystems.textsecuregcm.metrics.MetricsUtil;
|
||||
import org.whispersystems.textsecuregcm.metrics.UserAgentTagUtil;
|
||||
import org.whispersystems.textsecuregcm.storage.Account;
|
||||
import org.whispersystems.textsecuregcm.storage.ClientReleaseManager;
|
||||
import org.whispersystems.textsecuregcm.storage.Device;
|
||||
import org.whispersystems.textsecuregcm.storage.MessagesManager;
|
||||
import org.whispersystems.textsecuregcm.util.Util;
|
||||
@@ -52,7 +51,6 @@ public class MessageSender {
|
||||
|
||||
private final MessagesManager messagesManager;
|
||||
private final PushNotificationManager pushNotificationManager;
|
||||
private final ClientReleaseManager clientReleaseManager;
|
||||
|
||||
// Note that these names deliberately reference `MessageController` for metric continuity
|
||||
private static final String REJECT_OVERSIZE_MESSAGE_COUNTER_NAME = name(MessageSender.class, "rejectOversizeMessage");
|
||||
@@ -77,13 +75,9 @@ public class MessageSender {
|
||||
@VisibleForTesting
|
||||
static final byte NO_EXCLUDED_DEVICE_ID = -1;
|
||||
|
||||
public MessageSender(final MessagesManager messagesManager,
|
||||
final PushNotificationManager pushNotificationManager,
|
||||
final ClientReleaseManager clientReleaseManager) {
|
||||
|
||||
public MessageSender(final MessagesManager messagesManager, final PushNotificationManager pushNotificationManager) {
|
||||
this.messagesManager = messagesManager;
|
||||
this.pushNotificationManager = pushNotificationManager;
|
||||
this.clientReleaseManager = clientReleaseManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,15 +106,13 @@ public class MessageSender {
|
||||
@Nullable final String userAgent) throws MismatchedDevicesException, MessageTooLargeException {
|
||||
|
||||
final Tag platformTag = UserAgentTagUtil.getPlatformTag(userAgent);
|
||||
final Optional<Tag> maybeClientVersionTag = UserAgentTagUtil.getClientVersionTag(userAgent, clientReleaseManager);
|
||||
|
||||
validateIndividualMessageBundle(destination,
|
||||
destinationIdentifier,
|
||||
messagesByDeviceId,
|
||||
registrationIdsByDeviceId,
|
||||
syncMessageSenderDeviceId,
|
||||
platformTag,
|
||||
maybeClientVersionTag);
|
||||
platformTag);
|
||||
|
||||
messagesManager.insert(destination.getIdentifier(IdentityType.ACI), messagesByDeviceId)
|
||||
.forEach((deviceId, destinationPresent) -> {
|
||||
@@ -181,9 +173,8 @@ public class MessageSender {
|
||||
@Nullable final String userAgent) throws MultiRecipientMismatchedDevicesException, MessageTooLargeException {
|
||||
|
||||
final Tag platformTag = UserAgentTagUtil.getPlatformTag(userAgent);
|
||||
final Optional<Tag> maybeClientVersionTag = UserAgentTagUtil.getClientVersionTag(userAgent, clientReleaseManager);
|
||||
|
||||
validateMultiRecipientMessageContentLength(multiRecipientMessage, isStory, platformTag, maybeClientVersionTag);
|
||||
validateMultiRecipientMessageContentLength(multiRecipientMessage, isStory, platformTag);
|
||||
|
||||
final Map<ServiceIdentifier, MismatchedDevices> mismatchedDevicesByServiceIdentifier = new HashMap<>();
|
||||
|
||||
@@ -262,16 +253,14 @@ public class MessageSender {
|
||||
final Map<Byte, Envelope> messagesByDeviceId,
|
||||
final Map<Byte, Integer> registrationIdsByDeviceId,
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") final Optional<Byte> syncMessageSenderDeviceId,
|
||||
@Nullable final String userAgent,
|
||||
final ClientReleaseManager clientReleaseManager) throws MessageTooLargeException, MismatchedDevicesException {
|
||||
@Nullable final String userAgent) throws MessageTooLargeException, MismatchedDevicesException {
|
||||
|
||||
validateIndividualMessageBundle(destination,
|
||||
destinationIdentifier,
|
||||
messagesByDeviceId,
|
||||
registrationIdsByDeviceId,
|
||||
syncMessageSenderDeviceId,
|
||||
UserAgentTagUtil.getPlatformTag(userAgent),
|
||||
UserAgentTagUtil.getClientVersionTag(userAgent, clientReleaseManager));
|
||||
UserAgentTagUtil.getPlatformTag(userAgent));
|
||||
}
|
||||
|
||||
private static void validateIndividualMessageBundle(final Account destination,
|
||||
@@ -279,8 +268,7 @@ public class MessageSender {
|
||||
final Map<Byte, Envelope> messagesByDeviceId,
|
||||
final Map<Byte, Integer> registrationIdsByDeviceId,
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") final Optional<Byte> syncMessageSenderDeviceId,
|
||||
final Tag platformTag,
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") final Optional<Tag> maybeClientVersionTag) throws MismatchedDevicesException, MessageTooLargeException {
|
||||
final Tag platformTag) throws MismatchedDevicesException, MessageTooLargeException {
|
||||
|
||||
if (!destination.isIdentifiedBy(destinationIdentifier)) {
|
||||
throw new IllegalArgumentException("Destination account not identified by destination service identifier");
|
||||
@@ -317,10 +305,7 @@ public class MessageSender {
|
||||
throw new MismatchedDevicesException(maybeMismatchedDevices.get());
|
||||
}
|
||||
|
||||
validateIndividualMessageContentLength(messagesByDeviceId.values(),
|
||||
syncMessageSenderDeviceId.isPresent(),
|
||||
platformTag,
|
||||
maybeClientVersionTag);
|
||||
validateIndividualMessageContentLength(messagesByDeviceId.values(), syncMessageSenderDeviceId.isPresent(), platformTag);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -328,8 +313,7 @@ public class MessageSender {
|
||||
final boolean isMultiRecipientMessage,
|
||||
final boolean isSyncMessage,
|
||||
final boolean isStory,
|
||||
final Tag platformTag,
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") final Optional<Tag> maybeClientVersionTag) throws MessageTooLargeException {
|
||||
final Tag platformTag) throws MessageTooLargeException {
|
||||
|
||||
final boolean oversize = contentLength > MAX_MESSAGE_SIZE;
|
||||
|
||||
@@ -344,14 +328,11 @@ public class MessageSender {
|
||||
.record(contentLength);
|
||||
|
||||
if (contentLength > OVERSIZE_MESSAGE_WARNING_THRESHOLD) {
|
||||
Tags tags = Tags.of(platformTag,
|
||||
Tag.of("multiRecipientMessage", String.valueOf(isMultiRecipientMessage)),
|
||||
Tag.of("syncMessage", String.valueOf(isSyncMessage)),
|
||||
Tag.of("story", String.valueOf(isStory)));
|
||||
|
||||
tags = maybeClientVersionTag.map(tags::and).orElse(tags);
|
||||
|
||||
Metrics.counter(OVERSIZE_MESSAGE_WARNING_COUNTER_NAME, tags).increment();
|
||||
Metrics.counter(OVERSIZE_MESSAGE_WARNING_COUNTER_NAME, Tags.of(platformTag,
|
||||
Tag.of("multiRecipientMessage", String.valueOf(isMultiRecipientMessage)),
|
||||
Tag.of("syncMessage", String.valueOf(isSyncMessage)),
|
||||
Tag.of("story", String.valueOf(isStory))))
|
||||
.increment();
|
||||
}
|
||||
|
||||
if (oversize) {
|
||||
@@ -406,31 +387,27 @@ public class MessageSender {
|
||||
|
||||
private static void validateIndividualMessageContentLength(final Iterable<Envelope> messages,
|
||||
final boolean isSyncMessage,
|
||||
final Tag platformTag,
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") final Optional<Tag> maybeClientVersionTag) throws MessageTooLargeException {
|
||||
final Tag platformTag) throws MessageTooLargeException {
|
||||
|
||||
for (final Envelope message : messages) {
|
||||
MessageSender.validateContentLength(message.getContent().size(),
|
||||
false,
|
||||
isSyncMessage,
|
||||
message.getStory(),
|
||||
platformTag,
|
||||
maybeClientVersionTag);
|
||||
platformTag);
|
||||
}
|
||||
}
|
||||
|
||||
private static void validateMultiRecipientMessageContentLength(final SealedSenderMultiRecipientMessage multiRecipientMessage,
|
||||
final boolean isStory,
|
||||
final Tag platformTag,
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") final Optional<Tag> maybeClientVersionTag) throws MessageTooLargeException {
|
||||
final Tag platformTag) throws MessageTooLargeException {
|
||||
|
||||
for (final SealedSenderMultiRecipientMessage.Recipient recipient : multiRecipientMessage.getRecipients().values()) {
|
||||
MessageSender.validateContentLength(multiRecipientMessage.messageSizeForRecipient(recipient),
|
||||
true,
|
||||
false,
|
||||
isStory,
|
||||
platformTag,
|
||||
maybeClientVersionTag);
|
||||
platformTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,18 +27,15 @@ public class ChangeNumberManager {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ChangeNumberManager.class);
|
||||
private final MessageSender messageSender;
|
||||
private final AccountsManager accountsManager;
|
||||
private final ClientReleaseManager clientReleaseManager;
|
||||
private final Clock clock;
|
||||
|
||||
public ChangeNumberManager(
|
||||
final MessageSender messageSender,
|
||||
final AccountsManager accountsManager,
|
||||
final ClientReleaseManager clientReleaseManager,
|
||||
final Clock clock) {
|
||||
|
||||
this.messageSender = messageSender;
|
||||
this.accountsManager = accountsManager;
|
||||
this.clientReleaseManager = clientReleaseManager;
|
||||
this.clock = clock;
|
||||
}
|
||||
|
||||
@@ -79,8 +76,7 @@ public class ChangeNumberManager {
|
||||
messagesByDeviceId,
|
||||
registrationIdsByDeviceId,
|
||||
Optional.of(Device.PRIMARY_ID),
|
||||
senderUserAgent,
|
||||
clientReleaseManager);
|
||||
senderUserAgent);
|
||||
}
|
||||
|
||||
final Account updatedAccount = accountsManager.changeNumber(
|
||||
|
||||
Reference in New Issue
Block a user