kopia lustrzana https://github.com/ryukoposting/Signal-Android
Prefer ServiceIds over SignalServiceAddresses.
rodzic
6d4dadea48
commit
3beb730edb
|
@ -111,7 +111,7 @@ public class MultiDeviceMessageRequestResponseJob extends BaseJob {
|
||||||
if (recipient.isGroup()) {
|
if (recipient.isGroup()) {
|
||||||
response = MessageRequestResponseMessage.forGroup(recipient.getGroupId().get().getDecodedId(), localToRemoteType(type));
|
response = MessageRequestResponseMessage.forGroup(recipient.getGroupId().get().getDecodedId(), localToRemoteType(type));
|
||||||
} else if (recipient.isMaybeRegistered()) {
|
} else if (recipient.isMaybeRegistered()) {
|
||||||
response = MessageRequestResponseMessage.forIndividual(RecipientUtil.toSignalServiceAddress(context, recipient), localToRemoteType(type));
|
response = MessageRequestResponseMessage.forIndividual(RecipientUtil.getOrFetchServiceId(context, recipient), localToRemoteType(type));
|
||||||
} else {
|
} else {
|
||||||
response = null;
|
response = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,11 @@ import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
import org.thoughtcrime.securesms.net.NotPushRegisteredException;
|
import org.thoughtcrime.securesms.net.NotPushRegisteredException;
|
||||||
import org.thoughtcrime.securesms.payments.proto.PaymentMetaData;
|
import org.thoughtcrime.securesms.payments.proto.PaymentMetaData;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
|
import org.thoughtcrime.securesms.recipients.RecipientUtil;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.whispersystems.signalservice.api.messages.multidevice.OutgoingPaymentMessage;
|
import org.whispersystems.signalservice.api.messages.multidevice.OutgoingPaymentMessage;
|
||||||
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
|
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
|
||||||
|
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
|
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.ServerRejectedException;
|
import org.whispersystems.signalservice.api.push.exceptions.ServerRejectedException;
|
||||||
|
@ -89,9 +91,9 @@ public final class MultiDeviceOutgoingPaymentSyncJob extends BaseJob {
|
||||||
|
|
||||||
boolean defrag = payment.isDefrag();
|
boolean defrag = payment.isDefrag();
|
||||||
|
|
||||||
Optional<SignalServiceAddress> uuid;
|
Optional<ServiceId> uuid;
|
||||||
if (!defrag && payment.getPayee().hasRecipientId()) {
|
if (!defrag && payment.getPayee().hasRecipientId()) {
|
||||||
uuid = Optional.of(new SignalServiceAddress(Recipient.resolved(payment.getPayee().requireRecipientId()).requireServiceId()));
|
uuid = Optional.of(RecipientUtil.getOrFetchServiceId(context, Recipient.resolved(payment.getPayee().requireRecipientId())));
|
||||||
} else {
|
} else {
|
||||||
uuid = Optional.empty();
|
uuid = Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class MultiDeviceReadUpdateJob extends BaseJob {
|
||||||
for (SerializableSyncMessageId messageId : messageIds) {
|
for (SerializableSyncMessageId messageId : messageIds) {
|
||||||
Recipient recipient = Recipient.resolved(RecipientId.from(messageId.recipientId));
|
Recipient recipient = Recipient.resolved(RecipientId.from(messageId.recipientId));
|
||||||
if (!recipient.isGroup() && !recipient.isDistributionList() && recipient.isMaybeRegistered()) {
|
if (!recipient.isGroup() && !recipient.isDistributionList() && recipient.isMaybeRegistered()) {
|
||||||
readMessages.add(new ReadMessage(RecipientUtil.toSignalServiceAddress(context, recipient), messageId.timestamp));
|
readMessages.add(new ReadMessage(RecipientUtil.getOrFetchServiceId(context, recipient), messageId.timestamp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class MultiDeviceViewOnceOpenJob extends BaseJob {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewOnceOpenMessage openMessage = new ViewOnceOpenMessage(RecipientUtil.toSignalServiceAddress(context, recipient), messageId.timestamp);
|
ViewOnceOpenMessage openMessage = new ViewOnceOpenMessage(RecipientUtil.getOrFetchServiceId(context, recipient), messageId.timestamp);
|
||||||
|
|
||||||
messageSender.sendSyncMessage(SignalServiceSyncMessage.forViewOnceOpen(openMessage), UnidentifiedAccessUtil.getAccessForSync(context));
|
messageSender.sendSyncMessage(SignalServiceSyncMessage.forViewOnceOpen(openMessage), UnidentifiedAccessUtil.getAccessForSync(context));
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class MultiDeviceViewedUpdateJob extends BaseJob {
|
||||||
for (SerializableSyncMessageId messageId : messageIds) {
|
for (SerializableSyncMessageId messageId : messageIds) {
|
||||||
Recipient recipient = Recipient.resolved(RecipientId.from(messageId.recipientId));
|
Recipient recipient = Recipient.resolved(RecipientId.from(messageId.recipientId));
|
||||||
if (!recipient.isGroup() && recipient.isMaybeRegistered()) {
|
if (!recipient.isGroup() && recipient.isMaybeRegistered()) {
|
||||||
viewedMessages.add(new ViewedMessage(RecipientUtil.toSignalServiceAddress(context, recipient), messageId.timestamp));
|
viewedMessages.add(new ViewedMessage(RecipientUtil.getOrFetchServiceId(context, recipient), messageId.timestamp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -355,8 +355,7 @@ public abstract class PushSendJob extends SendJob {
|
||||||
Recipient quoteAuthorRecipient = Recipient.resolved(quoteAuthor);
|
Recipient quoteAuthorRecipient = Recipient.resolved(quoteAuthor);
|
||||||
|
|
||||||
if (quoteAuthorRecipient.isMaybeRegistered()) {
|
if (quoteAuthorRecipient.isMaybeRegistered()) {
|
||||||
SignalServiceAddress quoteAddress = RecipientUtil.toSignalServiceAddress(context, quoteAuthorRecipient);
|
return Optional.of(new SignalServiceDataMessage.Quote(quoteId, RecipientUtil.getOrFetchServiceId(context, quoteAuthorRecipient), quoteBody, quoteAttachments, quoteMentions, quoteType.getDataMessageType()));
|
||||||
return Optional.of(new SignalServiceDataMessage.Quote(quoteId, quoteAddress, quoteBody, quoteAttachments, quoteMentions, quoteType.getDataMessageType()));
|
|
||||||
} else {
|
} else {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -386,10 +385,10 @@ public abstract class PushSendJob extends SendJob {
|
||||||
|
|
||||||
protected Optional<SignalServiceDataMessage.Reaction> getStoryReactionFor(@NonNull OutgoingMediaMessage message, @NonNull SignalServiceDataMessage.StoryContext storyContext) {
|
protected Optional<SignalServiceDataMessage.Reaction> getStoryReactionFor(@NonNull OutgoingMediaMessage message, @NonNull SignalServiceDataMessage.StoryContext storyContext) {
|
||||||
if (message.isStoryReaction()) {
|
if (message.isStoryReaction()) {
|
||||||
return Optional.of(new SignalServiceDataMessage.Reaction(
|
return Optional.of(new SignalServiceDataMessage.Reaction(message.getBody(),
|
||||||
message.getBody(),
|
false,
|
||||||
false,
|
storyContext.getAuthorServiceId(),
|
||||||
new SignalServiceAddress(storyContext.getAuthorServiceId()), storyContext.getSentTimestamp()));
|
storyContext.getSentTimestamp()));
|
||||||
} else {
|
} else {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,7 +260,7 @@ public class ReactionSendJob extends BaseJob {
|
||||||
{
|
{
|
||||||
return new SignalServiceDataMessage.Reaction(reaction.getEmoji(),
|
return new SignalServiceDataMessage.Reaction(reaction.getEmoji(),
|
||||||
remove,
|
remove,
|
||||||
RecipientUtil.toSignalServiceAddress(context, targetAuthor),
|
RecipientUtil.getOrFetchServiceId(context, targetAuthor),
|
||||||
targetSentTimestamp);
|
targetSentTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2305,7 +2305,7 @@ public final class MessageContentProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<org.signal.libsignal.protocol.util.Pair<RecipientId, Boolean>> unidentifiedStatus = Stream.of(members)
|
List<org.signal.libsignal.protocol.util.Pair<RecipientId, Boolean>> unidentifiedStatus = Stream.of(members)
|
||||||
.map(m -> new org.signal.libsignal.protocol.util.Pair<>(m.getId(), message.isUnidentified(m.requireServiceId().toString())))
|
.map(m -> new org.signal.libsignal.protocol.util.Pair<>(m.getId(), message.isUnidentified(m.requireServiceId())))
|
||||||
.toList();
|
.toList();
|
||||||
receiptDatabase.setUnidentified(unidentifiedStatus, messageId);
|
receiptDatabase.setUnidentified(unidentifiedStatus, messageId);
|
||||||
}
|
}
|
||||||
|
@ -3132,16 +3132,11 @@ public final class MessageContentProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isUnidentified(@NonNull SentTranscriptMessage message, @NonNull Recipient recipient) {
|
private static boolean isUnidentified(@NonNull SentTranscriptMessage message, @NonNull Recipient recipient) {
|
||||||
boolean unidentified = false;
|
|
||||||
|
|
||||||
if (recipient.hasE164()) {
|
|
||||||
unidentified |= message.isUnidentified(recipient.requireE164());
|
|
||||||
}
|
|
||||||
if (recipient.hasServiceId()) {
|
if (recipient.hasServiceId()) {
|
||||||
unidentified |= message.isUnidentified(recipient.requireServiceId());
|
return message.isUnidentified(recipient.requireServiceId());
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return unidentified;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void log(@NonNull String message) {
|
private static void log(@NonNull String message) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||||
import org.thoughtcrime.securesms.mms.OutgoingExpirationUpdateMessage;
|
import org.thoughtcrime.securesms.mms.OutgoingExpirationUpdateMessage;
|
||||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper;
|
import org.thoughtcrime.securesms.storage.StorageSyncHelper;
|
||||||
|
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.NotFoundException;
|
import org.whispersystems.signalservice.api.push.exceptions.NotFoundException;
|
||||||
|
|
||||||
|
@ -39,6 +40,16 @@ public class RecipientUtil {
|
||||||
|
|
||||||
private static final String TAG = Log.tag(RecipientUtil.class);
|
private static final String TAG = Log.tag(RecipientUtil.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will do it's best to get a {@link ServiceId} for the provided recipient. This includes performing
|
||||||
|
* a possible network request if no ServiceId is available. If the request to get a ServiceId fails or the user is
|
||||||
|
* not registered, an IOException is thrown.
|
||||||
|
*/
|
||||||
|
@WorkerThread
|
||||||
|
public static @NonNull ServiceId getOrFetchServiceId(@NonNull Context context, @NonNull Recipient recipient) throws IOException {
|
||||||
|
return toSignalServiceAddress(context, recipient).getServiceId();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will do it's best to craft a fully-populated {@link SignalServiceAddress} based on
|
* This method will do it's best to craft a fully-populated {@link SignalServiceAddress} based on
|
||||||
* the provided recipient. This includes performing a possible network request if no UUID is
|
* the provided recipient. This includes performing a possible network request if no UUID is
|
||||||
|
|
|
@ -868,7 +868,7 @@ public class SignalServiceMessageSender {
|
||||||
DataMessage.Quote.Builder quoteBuilder = DataMessage.Quote.newBuilder()
|
DataMessage.Quote.Builder quoteBuilder = DataMessage.Quote.newBuilder()
|
||||||
.setId(message.getQuote().get().getId())
|
.setId(message.getQuote().get().getId())
|
||||||
.setText(message.getQuote().get().getText())
|
.setText(message.getQuote().get().getText())
|
||||||
.setAuthorUuid(message.getQuote().get().getAuthor().getServiceId().toString())
|
.setAuthorUuid(message.getQuote().get().getAuthor().toString())
|
||||||
.setType(message.getQuote().get().getType().getProtoType());
|
.setType(message.getQuote().get().getType().getProtoType());
|
||||||
|
|
||||||
if (!message.getQuote().get().getMentions().isEmpty()) {
|
if (!message.getQuote().get().getMentions().isEmpty()) {
|
||||||
|
@ -951,7 +951,7 @@ public class SignalServiceMessageSender {
|
||||||
.setEmoji(message.getReaction().get().getEmoji())
|
.setEmoji(message.getReaction().get().getEmoji())
|
||||||
.setRemove(message.getReaction().get().isRemove())
|
.setRemove(message.getReaction().get().isRemove())
|
||||||
.setTargetSentTimestamp(message.getReaction().get().getTargetSentTimestamp())
|
.setTargetSentTimestamp(message.getReaction().get().getTargetSentTimestamp())
|
||||||
.setTargetAuthorUuid(message.getReaction().get().getTargetAuthor().getServiceId().toString());
|
.setTargetAuthorUuid(message.getReaction().get().getTargetAuthor().toString());
|
||||||
|
|
||||||
builder.setReaction(reactionBuilder.build());
|
builder.setReaction(reactionBuilder.build());
|
||||||
builder.setRequiredProtocolVersion(Math.max(DataMessage.ProtocolVersion.REACTIONS_VALUE, builder.getRequiredProtocolVersion()));
|
builder.setRequiredProtocolVersion(Math.max(DataMessage.ProtocolVersion.REACTIONS_VALUE, builder.getRequiredProtocolVersion()));
|
||||||
|
@ -1209,7 +1209,7 @@ public class SignalServiceMessageSender {
|
||||||
for (ReadMessage readMessage : readMessages) {
|
for (ReadMessage readMessage : readMessages) {
|
||||||
builder.addRead(SyncMessage.Read.newBuilder()
|
builder.addRead(SyncMessage.Read.newBuilder()
|
||||||
.setTimestamp(readMessage.getTimestamp())
|
.setTimestamp(readMessage.getTimestamp())
|
||||||
.setSenderUuid(readMessage.getSender().getServiceId().toString()));
|
.setSenderUuid(readMessage.getSender().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return container.setSyncMessage(builder).build();
|
return container.setSyncMessage(builder).build();
|
||||||
|
@ -1222,7 +1222,7 @@ public class SignalServiceMessageSender {
|
||||||
for (ViewedMessage readMessage : readMessages) {
|
for (ViewedMessage readMessage : readMessages) {
|
||||||
builder.addViewed(SyncMessage.Viewed.newBuilder()
|
builder.addViewed(SyncMessage.Viewed.newBuilder()
|
||||||
.setTimestamp(readMessage.getTimestamp())
|
.setTimestamp(readMessage.getTimestamp())
|
||||||
.setSenderUuid(readMessage.getSender().getServiceId().toString()));
|
.setSenderUuid(readMessage.getSender().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return container.setSyncMessage(builder).build();
|
return container.setSyncMessage(builder).build();
|
||||||
|
@ -1234,7 +1234,7 @@ public class SignalServiceMessageSender {
|
||||||
|
|
||||||
builder.setViewOnceOpen(SyncMessage.ViewOnceOpen.newBuilder()
|
builder.setViewOnceOpen(SyncMessage.ViewOnceOpen.newBuilder()
|
||||||
.setTimestamp(readMessage.getTimestamp())
|
.setTimestamp(readMessage.getTimestamp())
|
||||||
.setSenderUuid(readMessage.getSender().getServiceId().toString()));
|
.setSenderUuid(readMessage.getSender().toString()));
|
||||||
|
|
||||||
return container.setSyncMessage(builder).build();
|
return container.setSyncMessage(builder).build();
|
||||||
}
|
}
|
||||||
|
@ -1345,7 +1345,7 @@ public class SignalServiceMessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.getPerson().isPresent()) {
|
if (message.getPerson().isPresent()) {
|
||||||
responseMessage.setThreadUuid(message.getPerson().get().getServiceId().toString());
|
responseMessage.setThreadUuid(message.getPerson().get().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (message.getType()) {
|
switch (message.getType()) {
|
||||||
|
@ -1378,7 +1378,7 @@ public class SignalServiceMessageSender {
|
||||||
SyncMessage.OutgoingPayment.Builder paymentMessage = SyncMessage.OutgoingPayment.newBuilder();
|
SyncMessage.OutgoingPayment.Builder paymentMessage = SyncMessage.OutgoingPayment.newBuilder();
|
||||||
|
|
||||||
if (message.getRecipient().isPresent()) {
|
if (message.getRecipient().isPresent()) {
|
||||||
paymentMessage.setRecipientUuid(message.getRecipient().get().getServiceId().toString());
|
paymentMessage.setRecipientUuid(message.getRecipient().get().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.getNote().isPresent()) {
|
if (message.getNote().isPresent()) {
|
||||||
|
@ -1629,7 +1629,7 @@ public class SignalServiceMessageSender {
|
||||||
sentTimestamp,
|
sentTimestamp,
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
0,
|
0,
|
||||||
Collections.singletonMap(localAddress, false),
|
Collections.singletonMap(localAddress.getServiceId(), false),
|
||||||
false,
|
false,
|
||||||
Optional.of(message),
|
Optional.of(message),
|
||||||
manifest);
|
manifest);
|
||||||
|
@ -1642,7 +1642,7 @@ public class SignalServiceMessageSender {
|
||||||
message.getTimestamp(),
|
message.getTimestamp(),
|
||||||
Optional.of(message),
|
Optional.of(message),
|
||||||
message.getExpiresInSeconds(),
|
message.getExpiresInSeconds(),
|
||||||
Collections.singletonMap(localAddress, false),
|
Collections.singletonMap(localAddress.getServiceId(), false),
|
||||||
false,
|
false,
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
Collections.emptySet());
|
Collections.emptySet());
|
||||||
|
|
|
@ -677,7 +677,7 @@ public final class SignalServiceContent {
|
||||||
throws ProtocolInvalidKeyException, UnsupportedDataMessageException, InvalidMessageStructureException
|
throws ProtocolInvalidKeyException, UnsupportedDataMessageException, InvalidMessageStructureException
|
||||||
{
|
{
|
||||||
if (content.hasSent()) {
|
if (content.hasSent()) {
|
||||||
Map<SignalServiceAddress, Boolean> unidentifiedStatuses = new HashMap<>();
|
Map<ServiceId, Boolean> unidentifiedStatuses = new HashMap<>();
|
||||||
SignalServiceProtos.SyncMessage.Sent sentContent = content.getSent();
|
SignalServiceProtos.SyncMessage.Sent sentContent = content.getSent();
|
||||||
Optional<SignalServiceDataMessage> dataMessage = sentContent.hasMessage() ? Optional.of(createSignalServiceMessage(metadata, sentContent.getMessage())) : Optional.empty();
|
Optional<SignalServiceDataMessage> dataMessage = sentContent.hasMessage() ? Optional.of(createSignalServiceMessage(metadata, sentContent.getMessage())) : Optional.empty();
|
||||||
Optional<SignalServiceStoryMessage> storyMessage = sentContent.hasStoryMessage() ? Optional.of(createStoryMessage(sentContent.getStoryMessage())) : Optional.empty();
|
Optional<SignalServiceStoryMessage> storyMessage = sentContent.hasStoryMessage() ? Optional.of(createStoryMessage(sentContent.getStoryMessage())) : Optional.empty();
|
||||||
|
@ -697,8 +697,7 @@ public final class SignalServiceContent {
|
||||||
|
|
||||||
for (SignalServiceProtos.SyncMessage.Sent.UnidentifiedDeliveryStatus status : sentContent.getUnidentifiedStatusList()) {
|
for (SignalServiceProtos.SyncMessage.Sent.UnidentifiedDeliveryStatus status : sentContent.getUnidentifiedStatusList()) {
|
||||||
if (SignalServiceAddress.isValidAddress(status.getDestinationUuid(), null)) {
|
if (SignalServiceAddress.isValidAddress(status.getDestinationUuid(), null)) {
|
||||||
SignalServiceAddress recipient = new SignalServiceAddress(ServiceId.parseOrThrow(status.getDestinationUuid()));
|
unidentifiedStatuses.put(ServiceId.parseOrNull(status.getDestinationUuid()), status.getUnidentified());
|
||||||
unidentifiedStatuses.put(recipient, status.getUnidentified());
|
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Encountered an invalid UnidentifiedDeliveryStatus in a SentTranscript! Ignoring.");
|
Log.w(TAG, "Encountered an invalid UnidentifiedDeliveryStatus in a SentTranscript! Ignoring.");
|
||||||
}
|
}
|
||||||
|
@ -722,9 +721,9 @@ public final class SignalServiceContent {
|
||||||
List<ReadMessage> readMessages = new LinkedList<>();
|
List<ReadMessage> readMessages = new LinkedList<>();
|
||||||
|
|
||||||
for (SignalServiceProtos.SyncMessage.Read read : content.getReadList()) {
|
for (SignalServiceProtos.SyncMessage.Read read : content.getReadList()) {
|
||||||
if (SignalServiceAddress.isValidAddress(read.getSenderUuid())) {
|
ServiceId serviceId = ServiceId.parseOrNull(read.getSenderUuid());
|
||||||
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(read.getSenderUuid()));
|
if (serviceId != null) {
|
||||||
readMessages.add(new ReadMessage(address, read.getTimestamp()));
|
readMessages.add(new ReadMessage(serviceId, read.getTimestamp()));
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Encountered an invalid ReadMessage! Ignoring.");
|
Log.w(TAG, "Encountered an invalid ReadMessage! Ignoring.");
|
||||||
}
|
}
|
||||||
|
@ -737,9 +736,9 @@ public final class SignalServiceContent {
|
||||||
List<ViewedMessage> viewedMessages = new LinkedList<>();
|
List<ViewedMessage> viewedMessages = new LinkedList<>();
|
||||||
|
|
||||||
for (SignalServiceProtos.SyncMessage.Viewed viewed : content.getViewedList()) {
|
for (SignalServiceProtos.SyncMessage.Viewed viewed : content.getViewedList()) {
|
||||||
if (SignalServiceAddress.isValidAddress(viewed.getSenderUuid())) {
|
ServiceId serviceId = ServiceId.parseOrNull(viewed.getSenderUuid());
|
||||||
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(viewed.getSenderUuid()));
|
if (serviceId != null) {
|
||||||
viewedMessages.add(new ViewedMessage(address, viewed.getTimestamp()));
|
viewedMessages.add(new ViewedMessage(serviceId, viewed.getTimestamp()));
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Encountered an invalid ReadMessage! Ignoring.");
|
Log.w(TAG, "Encountered an invalid ReadMessage! Ignoring.");
|
||||||
}
|
}
|
||||||
|
@ -749,9 +748,9 @@ public final class SignalServiceContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content.hasViewOnceOpen()) {
|
if (content.hasViewOnceOpen()) {
|
||||||
if (SignalServiceAddress.isValidAddress(content.getViewOnceOpen().getSenderUuid())) {
|
ServiceId serviceId = ServiceId.parseOrNull(content.getViewOnceOpen().getSenderUuid());
|
||||||
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(content.getViewOnceOpen().getSenderUuid()));
|
if (serviceId != null) {
|
||||||
ViewOnceOpenMessage timerRead = new ViewOnceOpenMessage(address, content.getViewOnceOpen().getTimestamp());
|
ViewOnceOpenMessage timerRead = new ViewOnceOpenMessage(serviceId, content.getViewOnceOpen().getTimestamp());
|
||||||
return SignalServiceSyncMessage.forViewOnceOpen(timerRead);
|
return SignalServiceSyncMessage.forViewOnceOpen(timerRead);
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidMessageStructureException("ViewOnceOpen message has no sender!");
|
throw new InvalidMessageStructureException("ViewOnceOpen message has no sender!");
|
||||||
|
@ -874,10 +873,9 @@ public final class SignalServiceContent {
|
||||||
if (content.getMessageRequestResponse().hasGroupId()) {
|
if (content.getMessageRequestResponse().hasGroupId()) {
|
||||||
responseMessage = MessageRequestResponseMessage.forGroup(content.getMessageRequestResponse().getGroupId().toByteArray(), type);
|
responseMessage = MessageRequestResponseMessage.forGroup(content.getMessageRequestResponse().getGroupId().toByteArray(), type);
|
||||||
} else {
|
} else {
|
||||||
Optional<SignalServiceAddress> address = SignalServiceAddress.fromRaw(content.getMessageRequestResponse().getThreadUuid(), null);
|
ServiceId serviceId = ServiceId.parseOrNull(content.getMessageRequestResponse().getThreadUuid());
|
||||||
|
if (serviceId != null) {
|
||||||
if (address.isPresent()) {
|
responseMessage = MessageRequestResponseMessage.forIndividual(serviceId, type);
|
||||||
responseMessage = MessageRequestResponseMessage.forIndividual(address.get(), type);
|
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidMessageStructureException("Message request response has an invalid thread identifier!");
|
throw new InvalidMessageStructureException("Message request response has an invalid thread identifier!");
|
||||||
}
|
}
|
||||||
|
@ -894,7 +892,7 @@ public final class SignalServiceContent {
|
||||||
Money.MobileCoin amount = Money.picoMobileCoin(mobileCoin.getAmountPicoMob());
|
Money.MobileCoin amount = Money.picoMobileCoin(mobileCoin.getAmountPicoMob());
|
||||||
Money.MobileCoin fee = Money.picoMobileCoin(mobileCoin.getFeePicoMob());
|
Money.MobileCoin fee = Money.picoMobileCoin(mobileCoin.getFeePicoMob());
|
||||||
ByteString address = mobileCoin.getRecipientAddress();
|
ByteString address = mobileCoin.getRecipientAddress();
|
||||||
Optional<SignalServiceAddress> recipient = SignalServiceAddress.fromRaw(outgoingPayment.getRecipientUuid(), null);
|
Optional<ServiceId> recipient = Optional.ofNullable(ServiceId.parseOrNull(outgoingPayment.getRecipientUuid()));
|
||||||
|
|
||||||
return SignalServiceSyncMessage.forOutgoingPayment(new OutgoingPaymentMessage(recipient,
|
return SignalServiceSyncMessage.forOutgoingPayment(new OutgoingPaymentMessage(recipient,
|
||||||
amount,
|
amount,
|
||||||
|
@ -1034,11 +1032,10 @@ public final class SignalServiceContent {
|
||||||
attachment.hasThumbnail() ? createAttachmentPointer(attachment.getThumbnail()) : null));
|
attachment.hasThumbnail() ? createAttachmentPointer(attachment.getThumbnail()) : null));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SignalServiceAddress.isValidAddress(content.getQuote().getAuthorUuid())) {
|
ServiceId author = ServiceId.parseOrNull(content.getQuote().getAuthorUuid());
|
||||||
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(content.getQuote().getAuthorUuid()));
|
if (author != null) {
|
||||||
|
|
||||||
return new SignalServiceDataMessage.Quote(content.getQuote().getId(),
|
return new SignalServiceDataMessage.Quote(content.getQuote().getId(),
|
||||||
address,
|
author,
|
||||||
content.getQuote().getText(),
|
content.getQuote().getText(),
|
||||||
attachments,
|
attachments,
|
||||||
createMentions(content.getQuote().getBodyRangesList(), content.getQuote().getText(), isGroupV2),
|
createMentions(content.getQuote().getBodyRangesList(), content.getQuote().getText(), isGroupV2),
|
||||||
|
@ -1139,7 +1136,7 @@ public final class SignalServiceContent {
|
||||||
|
|
||||||
return new SignalServiceDataMessage.Reaction(reaction.getEmoji(),
|
return new SignalServiceDataMessage.Reaction(reaction.getEmoji(),
|
||||||
reaction.getRemove(),
|
reaction.getRemove(),
|
||||||
new SignalServiceAddress(serviceId),
|
serviceId,
|
||||||
reaction.getTargetSentTimestamp());
|
reaction.getTargetSentTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -453,14 +453,14 @@ public class SignalServiceDataMessage {
|
||||||
|
|
||||||
public static class Quote {
|
public static class Quote {
|
||||||
private final long id;
|
private final long id;
|
||||||
private final SignalServiceAddress author;
|
private final ServiceId author;
|
||||||
private final String text;
|
private final String text;
|
||||||
private final List<QuotedAttachment> attachments;
|
private final List<QuotedAttachment> attachments;
|
||||||
private final List<Mention> mentions;
|
private final List<Mention> mentions;
|
||||||
private final Type type;
|
private final Type type;
|
||||||
|
|
||||||
public Quote(long id,
|
public Quote(long id,
|
||||||
SignalServiceAddress author,
|
ServiceId author,
|
||||||
String text,
|
String text,
|
||||||
List<QuotedAttachment> attachments,
|
List<QuotedAttachment> attachments,
|
||||||
List<Mention> mentions,
|
List<Mention> mentions,
|
||||||
|
@ -478,7 +478,7 @@ public class SignalServiceDataMessage {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignalServiceAddress getAuthor() {
|
public ServiceId getAuthor() {
|
||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,12 +585,12 @@ public class SignalServiceDataMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Reaction {
|
public static class Reaction {
|
||||||
private final String emoji;
|
private final String emoji;
|
||||||
private final boolean remove;
|
private final boolean remove;
|
||||||
private final SignalServiceAddress targetAuthor;
|
private final ServiceId targetAuthor;
|
||||||
private final long targetSentTimestamp;
|
private final long targetSentTimestamp;
|
||||||
|
|
||||||
public Reaction(String emoji, boolean remove, SignalServiceAddress targetAuthor, long targetSentTimestamp) {
|
public Reaction(String emoji, boolean remove, ServiceId targetAuthor, long targetSentTimestamp) {
|
||||||
this.emoji = emoji;
|
this.emoji = emoji;
|
||||||
this.remove = remove;
|
this.remove = remove;
|
||||||
this.targetAuthor = targetAuthor;
|
this.targetAuthor = targetAuthor;
|
||||||
|
@ -605,7 +605,7 @@ public class SignalServiceDataMessage {
|
||||||
return remove;
|
return remove;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignalServiceAddress getTargetAuthor() {
|
public ServiceId getTargetAuthor() {
|
||||||
return targetAuthor;
|
return targetAuthor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,18 @@ package org.whispersystems.signalservice.api.messages.multidevice;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class MessageRequestResponseMessage {
|
public class MessageRequestResponseMessage {
|
||||||
|
|
||||||
private final Optional<SignalServiceAddress> person;
|
private final Optional<ServiceId> person;
|
||||||
private final Optional<byte[]> groupId;
|
private final Optional<byte[]> groupId;
|
||||||
private final Type type;
|
private final Type type;
|
||||||
|
|
||||||
public static MessageRequestResponseMessage forIndividual(SignalServiceAddress address, Type type) {
|
public static MessageRequestResponseMessage forIndividual(ServiceId address, Type type) {
|
||||||
return new MessageRequestResponseMessage(Optional.of(address), Optional.empty(), type);
|
return new MessageRequestResponseMessage(Optional.of(address), Optional.empty(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ public class MessageRequestResponseMessage {
|
||||||
return new MessageRequestResponseMessage(Optional.empty(), Optional.of(groupId), type);
|
return new MessageRequestResponseMessage(Optional.empty(), Optional.of(groupId), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MessageRequestResponseMessage(Optional<SignalServiceAddress> person,
|
private MessageRequestResponseMessage(Optional<ServiceId> person,
|
||||||
Optional<byte[]> groupId,
|
Optional<byte[]> groupId,
|
||||||
Type type)
|
Type type)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +30,7 @@ public class MessageRequestResponseMessage {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<SignalServiceAddress> getPerson() {
|
public Optional<ServiceId> getPerson() {
|
||||||
return person;
|
return person;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.whispersystems.signalservice.api.messages.multidevice;
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
|
|
||||||
import org.whispersystems.signalservice.api.payments.Money;
|
import org.whispersystems.signalservice.api.payments.Money;
|
||||||
|
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -10,18 +11,18 @@ import java.util.Optional;
|
||||||
|
|
||||||
public final class OutgoingPaymentMessage {
|
public final class OutgoingPaymentMessage {
|
||||||
|
|
||||||
private final Optional<SignalServiceAddress> recipient;
|
private final Optional<ServiceId> recipient;
|
||||||
private final Money.MobileCoin amount;
|
private final Money.MobileCoin amount;
|
||||||
private final Money.MobileCoin fee;
|
private final Money.MobileCoin fee;
|
||||||
private final ByteString receipt;
|
private final ByteString receipt;
|
||||||
private final long blockIndex;
|
private final long blockIndex;
|
||||||
private final long blockTimestamp;
|
private final long blockTimestamp;
|
||||||
private final Optional<byte[]> address;
|
private final Optional<byte[]> address;
|
||||||
private final Optional<String> note;
|
private final Optional<String> note;
|
||||||
private final List<ByteString> publicKeys;
|
private final List<ByteString> publicKeys;
|
||||||
private final List<ByteString> keyImages;
|
private final List<ByteString> keyImages;
|
||||||
|
|
||||||
public OutgoingPaymentMessage(Optional<SignalServiceAddress> recipient,
|
public OutgoingPaymentMessage(Optional<ServiceId> recipient,
|
||||||
Money.MobileCoin amount,
|
Money.MobileCoin amount,
|
||||||
Money.MobileCoin fee,
|
Money.MobileCoin fee,
|
||||||
ByteString receipt,
|
ByteString receipt,
|
||||||
|
@ -44,7 +45,7 @@ public final class OutgoingPaymentMessage {
|
||||||
this.keyImages = keyImages;
|
this.keyImages = keyImages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<SignalServiceAddress> getRecipient() {
|
public Optional<ServiceId> getRecipient() {
|
||||||
return recipient;
|
return recipient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
|
|
||||||
package org.whispersystems.signalservice.api.messages.multidevice;
|
package org.whispersystems.signalservice.api.messages.multidevice;
|
||||||
|
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||||
|
|
||||||
public class ReadMessage {
|
public class ReadMessage {
|
||||||
|
|
||||||
private final SignalServiceAddress sender;
|
private final ServiceId sender;
|
||||||
private final long timestamp;
|
private final long timestamp;
|
||||||
|
|
||||||
public ReadMessage(SignalServiceAddress sender, long timestamp) {
|
public ReadMessage(ServiceId sender, long timestamp) {
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class ReadMessage {
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignalServiceAddress getSender() {
|
public ServiceId getSender() {
|
||||||
return sender;
|
return sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,8 @@ public class SentTranscriptMessage {
|
||||||
private final long timestamp;
|
private final long timestamp;
|
||||||
private final long expirationStartTimestamp;
|
private final long expirationStartTimestamp;
|
||||||
private final Optional<SignalServiceDataMessage> message;
|
private final Optional<SignalServiceDataMessage> message;
|
||||||
private final Map<String, Boolean> unidentifiedStatusBySid;
|
private final Map<ServiceId, Boolean> unidentifiedStatusBySid;
|
||||||
private final Map<String, Boolean> unidentifiedStatusByE164;
|
private final Set<ServiceId> recipients;
|
||||||
private final Set<SignalServiceAddress> recipients;
|
|
||||||
private final boolean isRecipientUpdate;
|
private final boolean isRecipientUpdate;
|
||||||
private final Optional<SignalServiceStoryMessage> storyMessage;
|
private final Optional<SignalServiceStoryMessage> storyMessage;
|
||||||
private final Set<SignalServiceStoryMessageRecipient> storyMessageRecipients;
|
private final Set<SignalServiceStoryMessageRecipient> storyMessageRecipients;
|
||||||
|
@ -35,7 +34,7 @@ public class SentTranscriptMessage {
|
||||||
long timestamp,
|
long timestamp,
|
||||||
Optional<SignalServiceDataMessage> message,
|
Optional<SignalServiceDataMessage> message,
|
||||||
long expirationStartTimestamp,
|
long expirationStartTimestamp,
|
||||||
Map<SignalServiceAddress, Boolean> unidentifiedStatus,
|
Map<ServiceId, Boolean> unidentifiedStatus,
|
||||||
boolean isRecipientUpdate,
|
boolean isRecipientUpdate,
|
||||||
Optional<SignalServiceStoryMessage> storyMessage,
|
Optional<SignalServiceStoryMessage> storyMessage,
|
||||||
Set<SignalServiceStoryMessageRecipient> storyMessageRecipients)
|
Set<SignalServiceStoryMessageRecipient> storyMessageRecipients)
|
||||||
|
@ -44,20 +43,11 @@ public class SentTranscriptMessage {
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.expirationStartTimestamp = expirationStartTimestamp;
|
this.expirationStartTimestamp = expirationStartTimestamp;
|
||||||
this.unidentifiedStatusBySid = new HashMap<>();
|
this.unidentifiedStatusBySid = new HashMap<>(unidentifiedStatus);
|
||||||
this.unidentifiedStatusByE164 = new HashMap<>();
|
|
||||||
this.recipients = unidentifiedStatus.keySet();
|
this.recipients = unidentifiedStatus.keySet();
|
||||||
this.isRecipientUpdate = isRecipientUpdate;
|
this.isRecipientUpdate = isRecipientUpdate;
|
||||||
this.storyMessage = storyMessage;
|
this.storyMessage = storyMessage;
|
||||||
this.storyMessageRecipients = storyMessageRecipients;
|
this.storyMessageRecipients = storyMessageRecipients;
|
||||||
|
|
||||||
for (Map.Entry<SignalServiceAddress, Boolean> entry : unidentifiedStatus.entrySet()) {
|
|
||||||
unidentifiedStatusBySid.put(entry.getKey().getServiceId().toString(), entry.getValue());
|
|
||||||
|
|
||||||
if (entry.getKey().getNumber().isPresent()) {
|
|
||||||
unidentifiedStatusByE164.put(entry.getKey().getNumber().get(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<SignalServiceAddress> getDestination() {
|
public Optional<SignalServiceAddress> getDestination() {
|
||||||
|
@ -85,20 +75,10 @@ public class SentTranscriptMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUnidentified(ServiceId serviceId) {
|
public boolean isUnidentified(ServiceId serviceId) {
|
||||||
return isUnidentified(serviceId.toString());
|
return unidentifiedStatusBySid.getOrDefault(serviceId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUnidentified(String destination) {
|
public Set<ServiceId> getRecipients() {
|
||||||
if (unidentifiedStatusBySid.containsKey(destination)) {
|
|
||||||
return unidentifiedStatusBySid.get(destination);
|
|
||||||
} else if (unidentifiedStatusByE164.containsKey(destination)) {
|
|
||||||
return unidentifiedStatusByE164.get(destination);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<SignalServiceAddress> getRecipients() {
|
|
||||||
return recipients;
|
return recipients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package org.whispersystems.signalservice.api.messages.multidevice;
|
package org.whispersystems.signalservice.api.messages.multidevice;
|
||||||
|
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||||
|
|
||||||
public class ViewOnceOpenMessage {
|
public class ViewOnceOpenMessage {
|
||||||
|
|
||||||
private final SignalServiceAddress sender;
|
private final ServiceId sender;
|
||||||
private final long timestamp;
|
private final long timestamp;
|
||||||
|
|
||||||
public ViewOnceOpenMessage(SignalServiceAddress sender, long timestamp) {
|
public ViewOnceOpenMessage(ServiceId sender, long timestamp) {
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public class ViewOnceOpenMessage {
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignalServiceAddress getSender() {
|
public ServiceId getSender() {
|
||||||
return sender;
|
return sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package org.whispersystems.signalservice.api.messages.multidevice;
|
package org.whispersystems.signalservice.api.messages.multidevice;
|
||||||
|
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||||
|
|
||||||
public class ViewedMessage {
|
public class ViewedMessage {
|
||||||
|
|
||||||
private final SignalServiceAddress sender;
|
private final ServiceId sender;
|
||||||
private final long timestamp;
|
private final long timestamp;
|
||||||
|
|
||||||
public ViewedMessage(SignalServiceAddress sender, long timestamp) {
|
public ViewedMessage(ServiceId sender, long timestamp) {
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public class ViewedMessage {
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignalServiceAddress getSender() {
|
public ServiceId getSender() {
|
||||||
return sender;
|
return sender;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue