Remove `Envelope.source`

This commit is contained in:
Chris Eager 2022-07-29 14:55:14 -05:00 committed by Chris Eager
parent 2575372639
commit 3d2f7e731f
15 changed files with 52 additions and 79 deletions

View File

@ -446,8 +446,8 @@ public class MessageController {
long size = 0; long size = 0;
for (final OutgoingMessageEntity message : messageList.messages()) { for (final OutgoingMessageEntity message : messageList.messages()) {
size += message.content() == null ? 0 : message.content().length; size += message.content() == null ? 0 : message.content().length;
size += Util.isEmpty(message.source()) ? 0 : message.source().length(); size += message.sourceUuid() == null ? 0 : 36;
} }
return size; return size;

View File

@ -5,11 +5,11 @@
package org.whispersystems.textsecuregcm.entities; package org.whispersystems.textsecuregcm.entities;
import com.google.protobuf.ByteString; import com.google.protobuf.ByteString;
import org.apache.commons.lang3.StringUtils;
import org.whispersystems.textsecuregcm.storage.Account;
import javax.annotation.Nullable;
import java.util.Base64; import java.util.Base64;
import java.util.UUID; import java.util.UUID;
import javax.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
import org.whispersystems.textsecuregcm.storage.Account;
public record IncomingMessage(int type, long destinationDeviceId, int destinationRegistrationId, String content) { public record IncomingMessage(int type, long destinationDeviceId, int destinationRegistrationId, String content) {
@ -28,8 +28,7 @@ public record IncomingMessage(int type, long destinationDeviceId, int destinatio
.setDestinationUuid(destinationUuid.toString()); .setDestinationUuid(destinationUuid.toString());
if (sourceAccount != null && sourceDeviceId != null) { if (sourceAccount != null && sourceDeviceId != null) {
envelopeBuilder.setSource(sourceAccount.getNumber()) envelopeBuilder.setSourceUuid(sourceAccount.getUuid().toString())
.setSourceUuid(sourceAccount.getUuid().toString())
.setSourceDevice(sourceDeviceId.intValue()); .setSourceDevice(sourceDeviceId.intValue());
} }

View File

@ -6,15 +6,14 @@
package org.whispersystems.textsecuregcm.entities; package org.whispersystems.textsecuregcm.entities;
import com.google.protobuf.ByteString; import com.google.protobuf.ByteString;
import org.apache.commons.lang3.StringUtils;
import javax.annotation.Nullable;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import javax.annotation.Nullable;
public record OutgoingMessageEntity(UUID guid, int type, long timestamp, @Nullable String source, public record OutgoingMessageEntity(UUID guid, int type, long timestamp, @Nullable UUID sourceUuid, int sourceDevice,
@Nullable UUID sourceUuid, int sourceDevice, UUID destinationUuid, UUID destinationUuid, @Nullable UUID updatedPni, byte[] content,
@Nullable UUID updatedPni, byte[] content, long serverTimestamp) { long serverTimestamp) {
public MessageProtos.Envelope toEnvelope() { public MessageProtos.Envelope toEnvelope() {
final MessageProtos.Envelope.Builder builder = MessageProtos.Envelope.newBuilder() final MessageProtos.Envelope.Builder builder = MessageProtos.Envelope.newBuilder()
@ -24,13 +23,9 @@ public record OutgoingMessageEntity(UUID guid, int type, long timestamp, @Nullab
.setDestinationUuid(destinationUuid().toString()) .setDestinationUuid(destinationUuid().toString())
.setServerGuid(guid().toString()); .setServerGuid(guid().toString());
if (StringUtils.isNotEmpty(source())) { if (sourceUuid() != null) {
builder.setSource(source()) builder.setSourceUuid(sourceUuid().toString());
.setSourceDevice(sourceDevice()); builder.setSourceDevice(sourceDevice());
if (sourceUuid() != null) {
builder.setSourceUuid(sourceUuid().toString());
}
} }
if (content() != null) { if (content() != null) {
@ -49,7 +44,6 @@ public record OutgoingMessageEntity(UUID guid, int type, long timestamp, @Nullab
UUID.fromString(envelope.getServerGuid()), UUID.fromString(envelope.getServerGuid()),
envelope.getType().getNumber(), envelope.getType().getNumber(),
envelope.getTimestamp(), envelope.getTimestamp(),
envelope.hasSource() ? envelope.getSource() : null,
envelope.hasSourceUuid() ? UUID.fromString(envelope.getSourceUuid()) : null, envelope.hasSourceUuid() ? UUID.fromString(envelope.getSourceUuid()) : null,
envelope.getSourceDevice(), envelope.getSourceDevice(),
envelope.hasDestinationUuid() ? UUID.fromString(envelope.getDestinationUuid()) : null, envelope.hasDestinationUuid() ? UUID.fromString(envelope.getDestinationUuid()) : null,
@ -68,14 +62,14 @@ public record OutgoingMessageEntity(UUID guid, int type, long timestamp, @Nullab
} }
final OutgoingMessageEntity that = (OutgoingMessageEntity) o; final OutgoingMessageEntity that = (OutgoingMessageEntity) o;
return type == that.type && timestamp == that.timestamp && sourceDevice == that.sourceDevice return type == that.type && timestamp == that.timestamp && sourceDevice == that.sourceDevice
&& serverTimestamp == that.serverTimestamp && guid.equals(that.guid) && Objects.equals(source, that.source) && serverTimestamp == that.serverTimestamp && guid.equals(that.guid)
&& Objects.equals(sourceUuid, that.sourceUuid) && destinationUuid.equals(that.destinationUuid) && Objects.equals(sourceUuid, that.sourceUuid) && destinationUuid.equals(that.destinationUuid)
&& Objects.equals(updatedPni, that.updatedPni) && Arrays.equals(content, that.content); && Objects.equals(updatedPni, that.updatedPni) && Arrays.equals(content, that.content);
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = Objects.hash(guid, type, timestamp, source, sourceUuid, sourceDevice, destinationUuid, updatedPni, int result = Objects.hash(guid, type, timestamp, sourceUuid, sourceDevice, destinationUuid, updatedPni,
serverTimestamp); serverTimestamp);
result = 31 * result + Arrays.hashCode(content); result = 31 * result + Arrays.hashCode(content);
return result; return result;

View File

@ -49,7 +49,6 @@ public class ReceiptSender {
final Envelope.Builder message = Envelope.newBuilder() final Envelope.Builder message = Envelope.newBuilder()
.setServerTimestamp(System.currentTimeMillis()) .setServerTimestamp(System.currentTimeMillis())
.setSource(sourceAccount.getNumber())
.setSourceUuid(sourceAccount.getUuid().toString()) .setSourceUuid(sourceAccount.getUuid().toString())
.setSourceDevice((int) source.getAuthenticatedDevice().getId()) .setSourceDevice((int) source.getAuthenticatedDevice().getId())
.setDestinationUuid(destinationUuid.toString()) .setDestinationUuid(destinationUuid.toString())

View File

@ -6,12 +6,6 @@ package org.whispersystems.textsecuregcm.storage;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.protobuf.ByteString; import com.google.protobuf.ByteString;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -25,6 +19,12 @@ import org.whispersystems.textsecuregcm.entities.SignedPreKey;
import org.whispersystems.textsecuregcm.push.MessageSender; import org.whispersystems.textsecuregcm.push.MessageSender;
import org.whispersystems.textsecuregcm.push.NotPushRegisteredException; import org.whispersystems.textsecuregcm.push.NotPushRegisteredException;
import org.whispersystems.textsecuregcm.util.DestinationDeviceValidator; import org.whispersystems.textsecuregcm.util.DestinationDeviceValidator;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
public class ChangeNumberManager { public class ChangeNumberManager {
private static final Logger logger = LoggerFactory.getLogger(AccountController.class); private static final Logger logger = LoggerFactory.getLogger(AccountController.class);
@ -92,10 +92,10 @@ public class ChangeNumberManager {
void sendMessageToSelf( void sendMessageToSelf(
Account sourceAndDestinationAccount, Optional<Device> destinationDevice, IncomingMessage message) { Account sourceAndDestinationAccount, Optional<Device> destinationDevice, IncomingMessage message) {
Optional<byte[]> contents = MessageController.getMessageContent(message); Optional<byte[]> contents = MessageController.getMessageContent(message);
if (!contents.isPresent()) { if (contents.isEmpty()) {
logger.debug("empty message contents sending to self, ignoring"); logger.debug("empty message contents sending to self, ignoring");
return; return;
} else if (!destinationDevice.isPresent()) { } else if (destinationDevice.isEmpty()) {
logger.debug("destination device not present"); logger.debug("destination device not present");
return; return;
} }
@ -107,7 +107,6 @@ public class ChangeNumberManager {
.setServerTimestamp(serverTimestamp) .setServerTimestamp(serverTimestamp)
.setDestinationUuid(sourceAndDestinationAccount.getUuid().toString()) .setDestinationUuid(sourceAndDestinationAccount.getUuid().toString())
.setContent(ByteString.copyFrom(contents.get())) .setContent(ByteString.copyFrom(contents.get()))
.setSource(sourceAndDestinationAccount.getNumber())
.setSourceUuid(sourceAndDestinationAccount.getUuid().toString()) .setSourceUuid(sourceAndDestinationAccount.getUuid().toString())
.setSourceDevice((int) Device.MASTER_ID) .setSourceDevice((int) Device.MASTER_ID)
.setUpdatedPni(sourceAndDestinationAccount.getPhoneNumberIdentifier().toString()) .setUpdatedPni(sourceAndDestinationAccount.getPhoneNumberIdentifier().toString())

View File

@ -57,11 +57,6 @@ public class MessagesDynamoDb extends AbstractDynamoDbStore {
@Deprecated @Deprecated
private static final String KEY_TIMESTAMP = "TS"; private static final String KEY_TIMESTAMP = "TS";
@Deprecated
private static final String KEY_SOURCE = "SN";
@Deprecated
private static final String KEY_SOURCE_UUID = "SU"; private static final String KEY_SOURCE_UUID = "SU";
@Deprecated @Deprecated
@ -276,14 +271,13 @@ public class MessagesDynamoDb extends AbstractDynamoDbStore {
final UUID messageUuid = convertLocalIndexMessageUuidSortKey(item.get(LOCAL_INDEX_MESSAGE_UUID_KEY_SORT).b().asByteArray()); final UUID messageUuid = convertLocalIndexMessageUuidSortKey(item.get(LOCAL_INDEX_MESSAGE_UUID_KEY_SORT).b().asByteArray());
final int type = AttributeValues.getInt(item, KEY_TYPE, 0); final int type = AttributeValues.getInt(item, KEY_TYPE, 0);
final long timestamp = AttributeValues.getLong(item, KEY_TIMESTAMP, 0L); final long timestamp = AttributeValues.getLong(item, KEY_TIMESTAMP, 0L);
final String source = AttributeValues.getString(item, KEY_SOURCE, null);
final UUID sourceUuid = AttributeValues.getUUID(item, KEY_SOURCE_UUID, null); final UUID sourceUuid = AttributeValues.getUUID(item, KEY_SOURCE_UUID, null);
final int sourceDevice = AttributeValues.getInt(item, KEY_SOURCE_DEVICE, 0); final int sourceDevice = AttributeValues.getInt(item, KEY_SOURCE_DEVICE, 0);
final UUID destinationUuid = AttributeValues.getUUID(item, KEY_DESTINATION_UUID, null); final UUID destinationUuid = AttributeValues.getUUID(item, KEY_DESTINATION_UUID, null);
final byte[] content = AttributeValues.getByteArray(item, KEY_CONTENT, null); final byte[] content = AttributeValues.getByteArray(item, KEY_CONTENT, null);
final UUID updatedPni = AttributeValues.getUUID(item, KEY_UPDATED_PNI, null); final UUID updatedPni = AttributeValues.getUUID(item, KEY_UPDATED_PNI, null);
envelope = new OutgoingMessageEntity(messageUuid, type, timestamp, source, sourceUuid, sourceDevice, destinationUuid, envelope = new OutgoingMessageEntity(messageUuid, type, timestamp, sourceUuid, sourceDevice, destinationUuid,
updatedPni, content, sortKey.getServerTimestamp()).toEnvelope(); updatedPni, content, sortKey.getServerTimestamp()).toEnvelope();
GET_MESSAGE_WITH_ATTRIBUTES_COUNTER.increment(); GET_MESSAGE_WITH_ATTRIBUTES_COUNTER.increment();

View File

@ -39,8 +39,6 @@ import org.slf4j.LoggerFactory;
import org.whispersystems.textsecuregcm.auth.AuthenticatedAccount; import org.whispersystems.textsecuregcm.auth.AuthenticatedAccount;
import org.whispersystems.textsecuregcm.controllers.MessageController; import org.whispersystems.textsecuregcm.controllers.MessageController;
import org.whispersystems.textsecuregcm.controllers.NoSuchUserException; import org.whispersystems.textsecuregcm.controllers.NoSuchUserException;
import org.whispersystems.textsecuregcm.entities.OutgoingMessageEntity;
import org.whispersystems.textsecuregcm.entities.OutgoingMessageEntityList;
import org.whispersystems.textsecuregcm.metrics.UserAgentTagUtil; import org.whispersystems.textsecuregcm.metrics.UserAgentTagUtil;
import org.whispersystems.textsecuregcm.push.DisplacedPresenceListener; import org.whispersystems.textsecuregcm.push.DisplacedPresenceListener;
import org.whispersystems.textsecuregcm.push.ReceiptSender; import org.whispersystems.textsecuregcm.push.ReceiptSender;
@ -228,7 +226,9 @@ public class WebSocketConnection implements MessageAvailabilityListener, Displac
} }
private void sendDeliveryReceiptFor(Envelope message) { private void sendDeliveryReceiptFor(Envelope message) {
if (!message.hasSource()) return; if (!message.hasSourceUuid()) {
return;
}
try { try {
receiptSender.sendReceipt(auth, UUID.fromString(message.getSourceUuid()), message.getTimestamp()); receiptSender.sendReceipt(auth, UUID.fromString(message.getSourceUuid()), message.getTimestamp());

View File

@ -32,7 +32,6 @@ message Envelope {
} }
optional Type type = 1; optional Type type = 1;
optional string source = 2;
optional string source_uuid = 11; optional string source_uuid = 11;
optional uint32 source_device = 7; optional uint32 source_device = 7;
optional uint64 timestamp = 5; optional uint64 timestamp = 5;

View File

@ -34,7 +34,6 @@ import io.dropwizard.testing.junit5.ResourceExtension;
import io.lettuce.core.cluster.api.sync.RedisAdvancedClusterCommands; import io.lettuce.core.cluster.api.sync.RedisAdvancedClusterCommands;
import java.util.Arrays; import java.util.Arrays;
import java.util.Base64; import java.util.Base64;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@ -44,7 +43,6 @@ import java.util.stream.Stream;
import javax.ws.rs.client.Entity; import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory; import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -207,7 +205,7 @@ class MessageControllerTest {
ArgumentCaptor<Envelope> captor = ArgumentCaptor.forClass(Envelope.class); ArgumentCaptor<Envelope> captor = ArgumentCaptor.forClass(Envelope.class);
verify(messageSender, times(1)).sendMessage(any(Account.class), any(Device.class), captor.capture(), eq(false)); verify(messageSender, times(1)).sendMessage(any(Account.class), any(Device.class), captor.capture(), eq(false));
assertTrue(captor.getValue().hasSource()); assertTrue(captor.getValue().hasSourceUuid());
assertTrue(captor.getValue().hasSourceDevice()); assertTrue(captor.getValue().hasSourceDevice());
} }
@ -227,7 +225,7 @@ class MessageControllerTest {
ArgumentCaptor<Envelope> captor = ArgumentCaptor.forClass(Envelope.class); ArgumentCaptor<Envelope> captor = ArgumentCaptor.forClass(Envelope.class);
verify(messageSender, times(1)).sendMessage(any(Account.class), any(Device.class), captor.capture(), eq(false)); verify(messageSender, times(1)).sendMessage(any(Account.class), any(Device.class), captor.capture(), eq(false));
assertTrue(captor.getValue().hasSource()); assertTrue(captor.getValue().hasSourceUuid());
assertTrue(captor.getValue().hasSourceDevice()); assertTrue(captor.getValue().hasSourceDevice());
} }
@ -260,7 +258,7 @@ class MessageControllerTest {
ArgumentCaptor<Envelope> captor = ArgumentCaptor.forClass(Envelope.class); ArgumentCaptor<Envelope> captor = ArgumentCaptor.forClass(Envelope.class);
verify(messageSender, times(1)).sendMessage(any(Account.class), any(Device.class), captor.capture(), eq(false)); verify(messageSender, times(1)).sendMessage(any(Account.class), any(Device.class), captor.capture(), eq(false));
assertFalse(captor.getValue().hasSource()); assertFalse(captor.getValue().hasSourceUuid());
assertFalse(captor.getValue().hasSourceDevice()); assertFalse(captor.getValue().hasSourceDevice());
} }
@ -381,8 +379,10 @@ class MessageControllerTest {
final UUID updatedPniOne = UUID.randomUUID(); final UUID updatedPniOne = UUID.randomUUID();
List<Envelope> messages = List.of( List<Envelope> messages = List.of(
generateEnvelope(messageGuidOne, Envelope.Type.CIPHERTEXT_VALUE, timestampOne, "+14152222222", sourceUuid, 2, AuthHelper.VALID_UUID, updatedPniOne, "hi there".getBytes(), 0), generateEnvelope(messageGuidOne, Envelope.Type.CIPHERTEXT_VALUE, timestampOne, sourceUuid, 2,
generateEnvelope(messageGuidTwo, Envelope.Type.SERVER_DELIVERY_RECEIPT_VALUE, timestampTwo, "+14152222222", sourceUuid, 2, AuthHelper.VALID_UUID, null, null, 0) AuthHelper.VALID_UUID, updatedPniOne, "hi there".getBytes(), 0),
generateEnvelope(messageGuidTwo, Envelope.Type.SERVER_DELIVERY_RECEIPT_VALUE, timestampTwo, sourceUuid, 2,
AuthHelper.VALID_UUID, null, null, 0)
); );
OutgoingMessageEntityList messagesList = new OutgoingMessageEntityList(messages.stream() OutgoingMessageEntityList messagesList = new OutgoingMessageEntityList(messages.stream()
@ -420,8 +420,10 @@ class MessageControllerTest {
final long timestampTwo = 313388; final long timestampTwo = 313388;
final List<Envelope> messages = List.of( final List<Envelope> messages = List.of(
generateEnvelope(UUID.randomUUID(), Envelope.Type.CIPHERTEXT_VALUE, timestampOne, "+14152222222", UUID.randomUUID(), 2, AuthHelper.VALID_UUID, null, "hi there".getBytes(), 0), generateEnvelope(UUID.randomUUID(), Envelope.Type.CIPHERTEXT_VALUE, timestampOne, UUID.randomUUID(), 2,
generateEnvelope(UUID.randomUUID(), Envelope.Type.SERVER_DELIVERY_RECEIPT_VALUE, timestampTwo, "+14152222222", UUID.randomUUID(), 2, AuthHelper.VALID_UUID, null, null, 0) AuthHelper.VALID_UUID, null, "hi there".getBytes(), 0),
generateEnvelope(UUID.randomUUID(), Envelope.Type.SERVER_DELIVERY_RECEIPT_VALUE, timestampTwo,
UUID.randomUUID(), 2, AuthHelper.VALID_UUID, null, null, 0)
); );
when(messagesManager.getMessagesForDevice(eq(AuthHelper.VALID_UUID), eq(1L), anyString(), anyBoolean())) when(messagesManager.getMessagesForDevice(eq(AuthHelper.VALID_UUID), eq(1L), anyString(), anyBoolean()))
@ -446,12 +448,12 @@ class MessageControllerTest {
UUID uuid1 = UUID.randomUUID(); UUID uuid1 = UUID.randomUUID();
when(messagesManager.delete(AuthHelper.VALID_UUID, 1, uuid1, null)).thenReturn(Optional.of(generateEnvelope( when(messagesManager.delete(AuthHelper.VALID_UUID, 1, uuid1, null)).thenReturn(Optional.of(generateEnvelope(
uuid1, Envelope.Type.CIPHERTEXT_VALUE, uuid1, Envelope.Type.CIPHERTEXT_VALUE,
timestamp, "+14152222222", sourceUuid, 1, AuthHelper.VALID_UUID, null, "hi".getBytes(), 0))); timestamp, sourceUuid, 1, AuthHelper.VALID_UUID, null, "hi".getBytes(), 0)));
UUID uuid2 = UUID.randomUUID(); UUID uuid2 = UUID.randomUUID();
when(messagesManager.delete(AuthHelper.VALID_UUID, 1, uuid2, null)).thenReturn(Optional.of(generateEnvelope( when(messagesManager.delete(AuthHelper.VALID_UUID, 1, uuid2, null)).thenReturn(Optional.of(generateEnvelope(
uuid2, Envelope.Type.SERVER_DELIVERY_RECEIPT_VALUE, uuid2, Envelope.Type.SERVER_DELIVERY_RECEIPT_VALUE,
System.currentTimeMillis(), "+14152222222", sourceUuid, 1, AuthHelper.VALID_UUID, null, null, 0))); System.currentTimeMillis(), sourceUuid, 1, AuthHelper.VALID_UUID, null, null, 0)));
UUID uuid3 = UUID.randomUUID(); UUID uuid3 = UUID.randomUUID();
when(messagesManager.delete(AuthHelper.VALID_UUID, 1, uuid3, null)).thenReturn(Optional.empty()); when(messagesManager.delete(AuthHelper.VALID_UUID, 1, uuid3, null)).thenReturn(Optional.empty());
@ -631,8 +633,8 @@ class MessageControllerTest {
Arguments.of("fixtures/current_message_single_device_server_receipt_type.json", false) Arguments.of("fixtures/current_message_single_device_server_receipt_type.json", false)
); );
} }
private static Envelope generateEnvelope(UUID guid, int type, long timestamp, String source, UUID sourceUuid, private static Envelope generateEnvelope(UUID guid, int type, long timestamp, UUID sourceUuid,
int sourceDevice, UUID destinationUuid, UUID updatedPni, byte[] content, long serverTimestamp) { int sourceDevice, UUID destinationUuid, UUID updatedPni, byte[] content, long serverTimestamp) {
final MessageProtos.Envelope.Builder builder = MessageProtos.Envelope.newBuilder() final MessageProtos.Envelope.Builder builder = MessageProtos.Envelope.newBuilder()
@ -642,13 +644,9 @@ class MessageControllerTest {
.setDestinationUuid(destinationUuid.toString()) .setDestinationUuid(destinationUuid.toString())
.setServerGuid(guid.toString()); .setServerGuid(guid.toString());
if (StringUtils.isNotEmpty(source)) { if (sourceUuid != null) {
builder.setSource(source) builder.setSourceUuid(sourceUuid.toString());
.setSourceDevice(sourceDevice); builder.setSourceDevice(sourceDevice);
if (sourceUuid != null) {
builder.setSourceUuid(sourceUuid.toString());
}
} }
if (content != null) { if (content != null) {

View File

@ -20,7 +20,7 @@ class OutgoingMessageEntityTest {
@ParameterizedTest @ParameterizedTest
@MethodSource @MethodSource
void toFromEnvelope(@Nullable final String source, @Nullable final UUID sourceUuid, @Nullable final UUID updatedPni) { void toFromEnvelope(@Nullable final UUID sourceUuid, @Nullable final UUID updatedPni) {
final byte[] messageContent = new byte[16]; final byte[] messageContent = new byte[16];
new Random().nextBytes(messageContent); new Random().nextBytes(messageContent);
@ -30,9 +30,8 @@ class OutgoingMessageEntityTest {
final OutgoingMessageEntity outgoingMessageEntity = new OutgoingMessageEntity(UUID.randomUUID(), final OutgoingMessageEntity outgoingMessageEntity = new OutgoingMessageEntity(UUID.randomUUID(),
MessageProtos.Envelope.Type.CIPHERTEXT_VALUE, MessageProtos.Envelope.Type.CIPHERTEXT_VALUE,
messageTimestamp, messageTimestamp,
source, UUID.randomUUID(),
sourceUuid, sourceUuid != null ? (int) Device.MASTER_ID : 0,
source != null ? (int) Device.MASTER_ID : 0,
UUID.randomUUID(), UUID.randomUUID(),
updatedPni, updatedPni,
messageContent, messageContent,
@ -43,8 +42,8 @@ class OutgoingMessageEntityTest {
private static Stream<Arguments> toFromEnvelope() { private static Stream<Arguments> toFromEnvelope() {
return Stream.of( return Stream.of(
Arguments.of("+18005551234", UUID.randomUUID(), UUID.randomUUID()), Arguments.of(UUID.randomUUID(), UUID.randomUUID()),
Arguments.of("+18005551234", UUID.randomUUID(), null), Arguments.of(UUID.randomUUID(), null),
Arguments.of(null, null, UUID.randomUUID())); Arguments.of(null, UUID.randomUUID()));
} }
} }

View File

@ -130,7 +130,6 @@ public class ChangeNumberManagerTest {
assertEquals(aci, UUID.fromString(envelope.getDestinationUuid())); assertEquals(aci, UUID.fromString(envelope.getDestinationUuid()));
assertEquals(aci, UUID.fromString(envelope.getSourceUuid())); assertEquals(aci, UUID.fromString(envelope.getSourceUuid()));
assertEquals(changedE164, envelope.getSource());
assertEquals(Device.MASTER_ID, envelope.getSourceDevice()); assertEquals(Device.MASTER_ID, envelope.getSourceDevice());
assertEquals(updatedPhoneNumberIdentifiersByAccount.get(account), UUID.fromString(envelope.getUpdatedPni())); assertEquals(updatedPhoneNumberIdentifiersByAccount.get(account), UUID.fromString(envelope.getUpdatedPni()));
} }

View File

@ -227,7 +227,7 @@ class MessagesCacheTest {
if (!sealedSender) { if (!sealedSender) {
envelopeBuilder.setSourceDevice(random.nextInt(256)) envelopeBuilder.setSourceDevice(random.nextInt(256))
.setSource("+1" + RandomStringUtils.randomNumeric(10)); .setSourceUuid(UUID.randomUUID().toString());
} }
return envelopeBuilder.build(); return envelopeBuilder.build();

View File

@ -39,7 +39,6 @@ class MessagesDynamoDbTest {
MESSAGE1 = builder.build(); MESSAGE1 = builder.build();
builder.setType(MessageProtos.Envelope.Type.CIPHERTEXT); builder.setType(MessageProtos.Envelope.Type.CIPHERTEXT);
builder.setSource("12348675309");
builder.setSourceUuid(UUID.randomUUID().toString()); builder.setSourceUuid(UUID.randomUUID().toString());
builder.setSourceDevice(1); builder.setSourceDevice(1);
builder.setContent(ByteString.copyFromUtf8("MOO")); builder.setContent(ByteString.copyFromUtf8("MOO"));
@ -50,7 +49,6 @@ class MessagesDynamoDbTest {
MESSAGE2 = builder.build(); MESSAGE2 = builder.build();
builder.setType(MessageProtos.Envelope.Type.UNIDENTIFIED_SENDER); builder.setType(MessageProtos.Envelope.Type.UNIDENTIFIED_SENDER);
builder.clearSource();
builder.clearSourceUuid(); builder.clearSourceUuid();
builder.clearSourceDevice(); builder.clearSourceDevice();
builder.setContent(ByteString.copyFromUtf8("COW")); builder.setContent(ByteString.copyFromUtf8("COW"));

View File

@ -28,10 +28,8 @@ class MessagesManagerTest {
@Test @Test
void insert() { void insert() {
final String sourceNumber = "+12025551212";
final UUID sourceAci = UUID.randomUUID(); final UUID sourceAci = UUID.randomUUID();
final Envelope message = Envelope.newBuilder() final Envelope message = Envelope.newBuilder()
.setSource(sourceNumber)
.setSourceUuid(sourceAci.toString()) .setSourceUuid(sourceAci.toString())
.build(); .build();

View File

@ -272,7 +272,6 @@ class WebSocketConnectionTest {
final Envelope firstMessage = Envelope.newBuilder() final Envelope firstMessage = Envelope.newBuilder()
.setServerGuid(UUID.randomUUID().toString()) .setServerGuid(UUID.randomUUID().toString())
.setSource("sender1")
.setSourceUuid(UUID.randomUUID().toString()) .setSourceUuid(UUID.randomUUID().toString())
.setDestinationUuid(UUID.randomUUID().toString()) .setDestinationUuid(UUID.randomUUID().toString())
.setUpdatedPni(UUID.randomUUID().toString()) .setUpdatedPni(UUID.randomUUID().toString())
@ -283,7 +282,6 @@ class WebSocketConnectionTest {
final Envelope secondMessage = Envelope.newBuilder() final Envelope secondMessage = Envelope.newBuilder()
.setServerGuid(UUID.randomUUID().toString()) .setServerGuid(UUID.randomUUID().toString())
.setSource("sender2")
.setSourceUuid(senderTwoUuid.toString()) .setSourceUuid(senderTwoUuid.toString())
.setDestinationUuid(UUID.randomUUID().toString()) .setDestinationUuid(UUID.randomUUID().toString())
.setTimestamp(System.currentTimeMillis()) .setTimestamp(System.currentTimeMillis())
@ -854,7 +852,6 @@ class WebSocketConnectionTest {
.setType(Envelope.Type.CIPHERTEXT) .setType(Envelope.Type.CIPHERTEXT)
.setTimestamp(timestamp) .setTimestamp(timestamp)
.setServerTimestamp(0) .setServerTimestamp(0)
.setSource(sender)
.setSourceUuid(senderUuid.toString()) .setSourceUuid(senderUuid.toString())
.setSourceDevice(1) .setSourceDevice(1)
.setDestinationUuid(destinationUuid.toString()) .setDestinationUuid(destinationUuid.toString())