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()) {
|
||||
response = MessageRequestResponseMessage.forGroup(recipient.getGroupId().get().getDecodedId(), localToRemoteType(type));
|
||||
} else if (recipient.isMaybeRegistered()) {
|
||||
response = MessageRequestResponseMessage.forIndividual(RecipientUtil.toSignalServiceAddress(context, recipient), localToRemoteType(type));
|
||||
response = MessageRequestResponseMessage.forIndividual(RecipientUtil.getOrFetchServiceId(context, recipient), localToRemoteType(type));
|
||||
} else {
|
||||
response = null;
|
||||
}
|
||||
|
|
|
@ -15,9 +15,11 @@ import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
|||
import org.thoughtcrime.securesms.net.NotPushRegisteredException;
|
||||
import org.thoughtcrime.securesms.payments.proto.PaymentMetaData;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.OutgoingPaymentMessage;
|
||||
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.exceptions.PushNetworkException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.ServerRejectedException;
|
||||
|
@ -89,9 +91,9 @@ public final class MultiDeviceOutgoingPaymentSyncJob extends BaseJob {
|
|||
|
||||
boolean defrag = payment.isDefrag();
|
||||
|
||||
Optional<SignalServiceAddress> uuid;
|
||||
Optional<ServiceId> uuid;
|
||||
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 {
|
||||
uuid = Optional.empty();
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ public class MultiDeviceReadUpdateJob extends BaseJob {
|
|||
for (SerializableSyncMessageId messageId : messageIds) {
|
||||
Recipient recipient = Recipient.resolved(RecipientId.from(messageId.recipientId));
|
||||
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;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ public class MultiDeviceViewedUpdateJob extends BaseJob {
|
|||
for (SerializableSyncMessageId messageId : messageIds) {
|
||||
Recipient recipient = Recipient.resolved(RecipientId.from(messageId.recipientId));
|
||||
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);
|
||||
|
||||
if (quoteAuthorRecipient.isMaybeRegistered()) {
|
||||
SignalServiceAddress quoteAddress = RecipientUtil.toSignalServiceAddress(context, quoteAuthorRecipient);
|
||||
return Optional.of(new SignalServiceDataMessage.Quote(quoteId, quoteAddress, quoteBody, quoteAttachments, quoteMentions, quoteType.getDataMessageType()));
|
||||
return Optional.of(new SignalServiceDataMessage.Quote(quoteId, RecipientUtil.getOrFetchServiceId(context, quoteAuthorRecipient), quoteBody, quoteAttachments, quoteMentions, quoteType.getDataMessageType()));
|
||||
} else {
|
||||
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) {
|
||||
if (message.isStoryReaction()) {
|
||||
return Optional.of(new SignalServiceDataMessage.Reaction(
|
||||
message.getBody(),
|
||||
false,
|
||||
new SignalServiceAddress(storyContext.getAuthorServiceId()), storyContext.getSentTimestamp()));
|
||||
return Optional.of(new SignalServiceDataMessage.Reaction(message.getBody(),
|
||||
false,
|
||||
storyContext.getAuthorServiceId(),
|
||||
storyContext.getSentTimestamp()));
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ public class ReactionSendJob extends BaseJob {
|
|||
{
|
||||
return new SignalServiceDataMessage.Reaction(reaction.getEmoji(),
|
||||
remove,
|
||||
RecipientUtil.toSignalServiceAddress(context, targetAuthor),
|
||||
RecipientUtil.getOrFetchServiceId(context, targetAuthor),
|
||||
targetSentTimestamp);
|
||||
}
|
||||
|
||||
|
|
|
@ -2305,7 +2305,7 @@ public final class MessageContentProcessor {
|
|||
}
|
||||
|
||||
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();
|
||||
receiptDatabase.setUnidentified(unidentifiedStatus, messageId);
|
||||
}
|
||||
|
@ -3132,16 +3132,11 @@ public final class MessageContentProcessor {
|
|||
}
|
||||
|
||||
private static boolean isUnidentified(@NonNull SentTranscriptMessage message, @NonNull Recipient recipient) {
|
||||
boolean unidentified = false;
|
||||
|
||||
if (recipient.hasE164()) {
|
||||
unidentified |= message.isUnidentified(recipient.requireE164());
|
||||
}
|
||||
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) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
|||
import org.thoughtcrime.securesms.mms.OutgoingExpirationUpdateMessage;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
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.exceptions.NotFoundException;
|
||||
|
||||
|
@ -39,6 +40,16 @@ public class RecipientUtil {
|
|||
|
||||
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
|
||||
* 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()
|
||||
.setId(message.getQuote().get().getId())
|
||||
.setText(message.getQuote().get().getText())
|
||||
.setAuthorUuid(message.getQuote().get().getAuthor().getServiceId().toString())
|
||||
.setAuthorUuid(message.getQuote().get().getAuthor().toString())
|
||||
.setType(message.getQuote().get().getType().getProtoType());
|
||||
|
||||
if (!message.getQuote().get().getMentions().isEmpty()) {
|
||||
|
@ -951,7 +951,7 @@ public class SignalServiceMessageSender {
|
|||
.setEmoji(message.getReaction().get().getEmoji())
|
||||
.setRemove(message.getReaction().get().isRemove())
|
||||
.setTargetSentTimestamp(message.getReaction().get().getTargetSentTimestamp())
|
||||
.setTargetAuthorUuid(message.getReaction().get().getTargetAuthor().getServiceId().toString());
|
||||
.setTargetAuthorUuid(message.getReaction().get().getTargetAuthor().toString());
|
||||
|
||||
builder.setReaction(reactionBuilder.build());
|
||||
builder.setRequiredProtocolVersion(Math.max(DataMessage.ProtocolVersion.REACTIONS_VALUE, builder.getRequiredProtocolVersion()));
|
||||
|
@ -1209,7 +1209,7 @@ public class SignalServiceMessageSender {
|
|||
for (ReadMessage readMessage : readMessages) {
|
||||
builder.addRead(SyncMessage.Read.newBuilder()
|
||||
.setTimestamp(readMessage.getTimestamp())
|
||||
.setSenderUuid(readMessage.getSender().getServiceId().toString()));
|
||||
.setSenderUuid(readMessage.getSender().toString()));
|
||||
}
|
||||
|
||||
return container.setSyncMessage(builder).build();
|
||||
|
@ -1222,7 +1222,7 @@ public class SignalServiceMessageSender {
|
|||
for (ViewedMessage readMessage : readMessages) {
|
||||
builder.addViewed(SyncMessage.Viewed.newBuilder()
|
||||
.setTimestamp(readMessage.getTimestamp())
|
||||
.setSenderUuid(readMessage.getSender().getServiceId().toString()));
|
||||
.setSenderUuid(readMessage.getSender().toString()));
|
||||
}
|
||||
|
||||
return container.setSyncMessage(builder).build();
|
||||
|
@ -1234,7 +1234,7 @@ public class SignalServiceMessageSender {
|
|||
|
||||
builder.setViewOnceOpen(SyncMessage.ViewOnceOpen.newBuilder()
|
||||
.setTimestamp(readMessage.getTimestamp())
|
||||
.setSenderUuid(readMessage.getSender().getServiceId().toString()));
|
||||
.setSenderUuid(readMessage.getSender().toString()));
|
||||
|
||||
return container.setSyncMessage(builder).build();
|
||||
}
|
||||
|
@ -1345,7 +1345,7 @@ public class SignalServiceMessageSender {
|
|||
}
|
||||
|
||||
if (message.getPerson().isPresent()) {
|
||||
responseMessage.setThreadUuid(message.getPerson().get().getServiceId().toString());
|
||||
responseMessage.setThreadUuid(message.getPerson().get().toString());
|
||||
}
|
||||
|
||||
switch (message.getType()) {
|
||||
|
@ -1378,7 +1378,7 @@ public class SignalServiceMessageSender {
|
|||
SyncMessage.OutgoingPayment.Builder paymentMessage = SyncMessage.OutgoingPayment.newBuilder();
|
||||
|
||||
if (message.getRecipient().isPresent()) {
|
||||
paymentMessage.setRecipientUuid(message.getRecipient().get().getServiceId().toString());
|
||||
paymentMessage.setRecipientUuid(message.getRecipient().get().toString());
|
||||
}
|
||||
|
||||
if (message.getNote().isPresent()) {
|
||||
|
@ -1629,7 +1629,7 @@ public class SignalServiceMessageSender {
|
|||
sentTimestamp,
|
||||
Optional.empty(),
|
||||
0,
|
||||
Collections.singletonMap(localAddress, false),
|
||||
Collections.singletonMap(localAddress.getServiceId(), false),
|
||||
false,
|
||||
Optional.of(message),
|
||||
manifest);
|
||||
|
@ -1642,7 +1642,7 @@ public class SignalServiceMessageSender {
|
|||
message.getTimestamp(),
|
||||
Optional.of(message),
|
||||
message.getExpiresInSeconds(),
|
||||
Collections.singletonMap(localAddress, false),
|
||||
Collections.singletonMap(localAddress.getServiceId(), false),
|
||||
false,
|
||||
Optional.empty(),
|
||||
Collections.emptySet());
|
||||
|
|
|
@ -677,7 +677,7 @@ public final class SignalServiceContent {
|
|||
throws ProtocolInvalidKeyException, UnsupportedDataMessageException, InvalidMessageStructureException
|
||||
{
|
||||
if (content.hasSent()) {
|
||||
Map<SignalServiceAddress, Boolean> unidentifiedStatuses = new HashMap<>();
|
||||
Map<ServiceId, Boolean> unidentifiedStatuses = new HashMap<>();
|
||||
SignalServiceProtos.SyncMessage.Sent sentContent = content.getSent();
|
||||
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();
|
||||
|
@ -697,8 +697,7 @@ public final class SignalServiceContent {
|
|||
|
||||
for (SignalServiceProtos.SyncMessage.Sent.UnidentifiedDeliveryStatus status : sentContent.getUnidentifiedStatusList()) {
|
||||
if (SignalServiceAddress.isValidAddress(status.getDestinationUuid(), null)) {
|
||||
SignalServiceAddress recipient = new SignalServiceAddress(ServiceId.parseOrThrow(status.getDestinationUuid()));
|
||||
unidentifiedStatuses.put(recipient, status.getUnidentified());
|
||||
unidentifiedStatuses.put(ServiceId.parseOrNull(status.getDestinationUuid()), status.getUnidentified());
|
||||
} else {
|
||||
Log.w(TAG, "Encountered an invalid UnidentifiedDeliveryStatus in a SentTranscript! Ignoring.");
|
||||
}
|
||||
|
@ -722,9 +721,9 @@ public final class SignalServiceContent {
|
|||
List<ReadMessage> readMessages = new LinkedList<>();
|
||||
|
||||
for (SignalServiceProtos.SyncMessage.Read read : content.getReadList()) {
|
||||
if (SignalServiceAddress.isValidAddress(read.getSenderUuid())) {
|
||||
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(read.getSenderUuid()));
|
||||
readMessages.add(new ReadMessage(address, read.getTimestamp()));
|
||||
ServiceId serviceId = ServiceId.parseOrNull(read.getSenderUuid());
|
||||
if (serviceId != null) {
|
||||
readMessages.add(new ReadMessage(serviceId, read.getTimestamp()));
|
||||
} else {
|
||||
Log.w(TAG, "Encountered an invalid ReadMessage! Ignoring.");
|
||||
}
|
||||
|
@ -737,9 +736,9 @@ public final class SignalServiceContent {
|
|||
List<ViewedMessage> viewedMessages = new LinkedList<>();
|
||||
|
||||
for (SignalServiceProtos.SyncMessage.Viewed viewed : content.getViewedList()) {
|
||||
if (SignalServiceAddress.isValidAddress(viewed.getSenderUuid())) {
|
||||
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(viewed.getSenderUuid()));
|
||||
viewedMessages.add(new ViewedMessage(address, viewed.getTimestamp()));
|
||||
ServiceId serviceId = ServiceId.parseOrNull(viewed.getSenderUuid());
|
||||
if (serviceId != null) {
|
||||
viewedMessages.add(new ViewedMessage(serviceId, viewed.getTimestamp()));
|
||||
} else {
|
||||
Log.w(TAG, "Encountered an invalid ReadMessage! Ignoring.");
|
||||
}
|
||||
|
@ -749,9 +748,9 @@ public final class SignalServiceContent {
|
|||
}
|
||||
|
||||
if (content.hasViewOnceOpen()) {
|
||||
if (SignalServiceAddress.isValidAddress(content.getViewOnceOpen().getSenderUuid())) {
|
||||
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(content.getViewOnceOpen().getSenderUuid()));
|
||||
ViewOnceOpenMessage timerRead = new ViewOnceOpenMessage(address, content.getViewOnceOpen().getTimestamp());
|
||||
ServiceId serviceId = ServiceId.parseOrNull(content.getViewOnceOpen().getSenderUuid());
|
||||
if (serviceId != null) {
|
||||
ViewOnceOpenMessage timerRead = new ViewOnceOpenMessage(serviceId, content.getViewOnceOpen().getTimestamp());
|
||||
return SignalServiceSyncMessage.forViewOnceOpen(timerRead);
|
||||
} else {
|
||||
throw new InvalidMessageStructureException("ViewOnceOpen message has no sender!");
|
||||
|
@ -874,10 +873,9 @@ public final class SignalServiceContent {
|
|||
if (content.getMessageRequestResponse().hasGroupId()) {
|
||||
responseMessage = MessageRequestResponseMessage.forGroup(content.getMessageRequestResponse().getGroupId().toByteArray(), type);
|
||||
} else {
|
||||
Optional<SignalServiceAddress> address = SignalServiceAddress.fromRaw(content.getMessageRequestResponse().getThreadUuid(), null);
|
||||
|
||||
if (address.isPresent()) {
|
||||
responseMessage = MessageRequestResponseMessage.forIndividual(address.get(), type);
|
||||
ServiceId serviceId = ServiceId.parseOrNull(content.getMessageRequestResponse().getThreadUuid());
|
||||
if (serviceId != null) {
|
||||
responseMessage = MessageRequestResponseMessage.forIndividual(serviceId, type);
|
||||
} else {
|
||||
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 fee = Money.picoMobileCoin(mobileCoin.getFeePicoMob());
|
||||
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,
|
||||
amount,
|
||||
|
@ -1034,11 +1032,10 @@ public final class SignalServiceContent {
|
|||
attachment.hasThumbnail() ? createAttachmentPointer(attachment.getThumbnail()) : null));
|
||||
}
|
||||
|
||||
if (SignalServiceAddress.isValidAddress(content.getQuote().getAuthorUuid())) {
|
||||
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(content.getQuote().getAuthorUuid()));
|
||||
|
||||
ServiceId author = ServiceId.parseOrNull(content.getQuote().getAuthorUuid());
|
||||
if (author != null) {
|
||||
return new SignalServiceDataMessage.Quote(content.getQuote().getId(),
|
||||
address,
|
||||
author,
|
||||
content.getQuote().getText(),
|
||||
attachments,
|
||||
createMentions(content.getQuote().getBodyRangesList(), content.getQuote().getText(), isGroupV2),
|
||||
|
@ -1139,7 +1136,7 @@ public final class SignalServiceContent {
|
|||
|
||||
return new SignalServiceDataMessage.Reaction(reaction.getEmoji(),
|
||||
reaction.getRemove(),
|
||||
new SignalServiceAddress(serviceId),
|
||||
serviceId,
|
||||
reaction.getTargetSentTimestamp());
|
||||
}
|
||||
|
||||
|
|
|
@ -453,14 +453,14 @@ public class SignalServiceDataMessage {
|
|||
|
||||
public static class Quote {
|
||||
private final long id;
|
||||
private final SignalServiceAddress author;
|
||||
private final ServiceId author;
|
||||
private final String text;
|
||||
private final List<QuotedAttachment> attachments;
|
||||
private final List<Mention> mentions;
|
||||
private final Type type;
|
||||
|
||||
public Quote(long id,
|
||||
SignalServiceAddress author,
|
||||
ServiceId author,
|
||||
String text,
|
||||
List<QuotedAttachment> attachments,
|
||||
List<Mention> mentions,
|
||||
|
@ -478,7 +478,7 @@ public class SignalServiceDataMessage {
|
|||
return id;
|
||||
}
|
||||
|
||||
public SignalServiceAddress getAuthor() {
|
||||
public ServiceId getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
|
@ -585,12 +585,12 @@ public class SignalServiceDataMessage {
|
|||
}
|
||||
|
||||
public static class Reaction {
|
||||
private final String emoji;
|
||||
private final boolean remove;
|
||||
private final SignalServiceAddress targetAuthor;
|
||||
private final long targetSentTimestamp;
|
||||
private final String emoji;
|
||||
private final boolean remove;
|
||||
private final ServiceId targetAuthor;
|
||||
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.remove = remove;
|
||||
this.targetAuthor = targetAuthor;
|
||||
|
@ -605,7 +605,7 @@ public class SignalServiceDataMessage {
|
|||
return remove;
|
||||
}
|
||||
|
||||
public SignalServiceAddress getTargetAuthor() {
|
||||
public ServiceId getTargetAuthor() {
|
||||
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 java.util.Optional;
|
||||
|
||||
public class MessageRequestResponseMessage {
|
||||
|
||||
private final Optional<SignalServiceAddress> person;
|
||||
private final Optional<byte[]> groupId;
|
||||
private final Type type;
|
||||
private final Optional<ServiceId> person;
|
||||
private final Optional<byte[]> groupId;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -20,7 +21,7 @@ public class MessageRequestResponseMessage {
|
|||
return new MessageRequestResponseMessage(Optional.empty(), Optional.of(groupId), type);
|
||||
}
|
||||
|
||||
private MessageRequestResponseMessage(Optional<SignalServiceAddress> person,
|
||||
private MessageRequestResponseMessage(Optional<ServiceId> person,
|
||||
Optional<byte[]> groupId,
|
||||
Type type)
|
||||
{
|
||||
|
@ -29,7 +30,7 @@ public class MessageRequestResponseMessage {
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public Optional<SignalServiceAddress> getPerson() {
|
||||
public Optional<ServiceId> getPerson() {
|
||||
return person;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.whispersystems.signalservice.api.messages.multidevice;
|
|||
import com.google.protobuf.ByteString;
|
||||
|
||||
import org.whispersystems.signalservice.api.payments.Money;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -10,18 +11,18 @@ import java.util.Optional;
|
|||
|
||||
public final class OutgoingPaymentMessage {
|
||||
|
||||
private final Optional<SignalServiceAddress> recipient;
|
||||
private final Money.MobileCoin amount;
|
||||
private final Money.MobileCoin fee;
|
||||
private final ByteString receipt;
|
||||
private final long blockIndex;
|
||||
private final long blockTimestamp;
|
||||
private final Optional<byte[]> address;
|
||||
private final Optional<String> note;
|
||||
private final List<ByteString> publicKeys;
|
||||
private final List<ByteString> keyImages;
|
||||
private final Optional<ServiceId> recipient;
|
||||
private final Money.MobileCoin amount;
|
||||
private final Money.MobileCoin fee;
|
||||
private final ByteString receipt;
|
||||
private final long blockIndex;
|
||||
private final long blockTimestamp;
|
||||
private final Optional<byte[]> address;
|
||||
private final Optional<String> note;
|
||||
private final List<ByteString> publicKeys;
|
||||
private final List<ByteString> keyImages;
|
||||
|
||||
public OutgoingPaymentMessage(Optional<SignalServiceAddress> recipient,
|
||||
public OutgoingPaymentMessage(Optional<ServiceId> recipient,
|
||||
Money.MobileCoin amount,
|
||||
Money.MobileCoin fee,
|
||||
ByteString receipt,
|
||||
|
@ -44,7 +45,7 @@ public final class OutgoingPaymentMessage {
|
|||
this.keyImages = keyImages;
|
||||
}
|
||||
|
||||
public Optional<SignalServiceAddress> getRecipient() {
|
||||
public Optional<ServiceId> getRecipient() {
|
||||
return recipient;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
|
||||
package org.whispersystems.signalservice.api.messages.multidevice;
|
||||
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
|
||||
public class ReadMessage {
|
||||
|
||||
private final SignalServiceAddress sender;
|
||||
private final long timestamp;
|
||||
private final ServiceId sender;
|
||||
private final long timestamp;
|
||||
|
||||
public ReadMessage(SignalServiceAddress sender, long timestamp) {
|
||||
public ReadMessage(ServiceId sender, long timestamp) {
|
||||
this.sender = sender;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class ReadMessage {
|
|||
return timestamp;
|
||||
}
|
||||
|
||||
public SignalServiceAddress getSender() {
|
||||
public ServiceId getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,8 @@ public class SentTranscriptMessage {
|
|||
private final long timestamp;
|
||||
private final long expirationStartTimestamp;
|
||||
private final Optional<SignalServiceDataMessage> message;
|
||||
private final Map<String, Boolean> unidentifiedStatusBySid;
|
||||
private final Map<String, Boolean> unidentifiedStatusByE164;
|
||||
private final Set<SignalServiceAddress> recipients;
|
||||
private final Map<ServiceId, Boolean> unidentifiedStatusBySid;
|
||||
private final Set<ServiceId> recipients;
|
||||
private final boolean isRecipientUpdate;
|
||||
private final Optional<SignalServiceStoryMessage> storyMessage;
|
||||
private final Set<SignalServiceStoryMessageRecipient> storyMessageRecipients;
|
||||
|
@ -35,7 +34,7 @@ public class SentTranscriptMessage {
|
|||
long timestamp,
|
||||
Optional<SignalServiceDataMessage> message,
|
||||
long expirationStartTimestamp,
|
||||
Map<SignalServiceAddress, Boolean> unidentifiedStatus,
|
||||
Map<ServiceId, Boolean> unidentifiedStatus,
|
||||
boolean isRecipientUpdate,
|
||||
Optional<SignalServiceStoryMessage> storyMessage,
|
||||
Set<SignalServiceStoryMessageRecipient> storyMessageRecipients)
|
||||
|
@ -44,20 +43,11 @@ public class SentTranscriptMessage {
|
|||
this.timestamp = timestamp;
|
||||
this.message = message;
|
||||
this.expirationStartTimestamp = expirationStartTimestamp;
|
||||
this.unidentifiedStatusBySid = new HashMap<>();
|
||||
this.unidentifiedStatusByE164 = new HashMap<>();
|
||||
this.unidentifiedStatusBySid = new HashMap<>(unidentifiedStatus);
|
||||
this.recipients = unidentifiedStatus.keySet();
|
||||
this.isRecipientUpdate = isRecipientUpdate;
|
||||
this.storyMessage = storyMessage;
|
||||
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() {
|
||||
|
@ -85,20 +75,10 @@ public class SentTranscriptMessage {
|
|||
}
|
||||
|
||||
public boolean isUnidentified(ServiceId serviceId) {
|
||||
return isUnidentified(serviceId.toString());
|
||||
return unidentifiedStatusBySid.getOrDefault(serviceId, false);
|
||||
}
|
||||
|
||||
public boolean isUnidentified(String destination) {
|
||||
if (unidentifiedStatusBySid.containsKey(destination)) {
|
||||
return unidentifiedStatusBySid.get(destination);
|
||||
} else if (unidentifiedStatusByE164.containsKey(destination)) {
|
||||
return unidentifiedStatusByE164.get(destination);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Set<SignalServiceAddress> getRecipients() {
|
||||
public Set<ServiceId> getRecipients() {
|
||||
return recipients;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package org.whispersystems.signalservice.api.messages.multidevice;
|
||||
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
|
||||
public class ViewOnceOpenMessage {
|
||||
|
||||
private final SignalServiceAddress sender;
|
||||
private final long timestamp;
|
||||
private final ServiceId sender;
|
||||
private final long timestamp;
|
||||
|
||||
public ViewOnceOpenMessage(SignalServiceAddress sender, long timestamp) {
|
||||
public ViewOnceOpenMessage(ServiceId sender, long timestamp) {
|
||||
this.sender = sender;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class ViewOnceOpenMessage {
|
|||
return timestamp;
|
||||
}
|
||||
|
||||
public SignalServiceAddress getSender() {
|
||||
public ServiceId getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package org.whispersystems.signalservice.api.messages.multidevice;
|
||||
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
|
||||
public class ViewedMessage {
|
||||
|
||||
private final SignalServiceAddress sender;
|
||||
private final long timestamp;
|
||||
private final ServiceId sender;
|
||||
private final long timestamp;
|
||||
|
||||
public ViewedMessage(SignalServiceAddress sender, long timestamp) {
|
||||
public ViewedMessage(ServiceId sender, long timestamp) {
|
||||
this.sender = sender;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class ViewedMessage {
|
|||
return timestamp;
|
||||
}
|
||||
|
||||
public SignalServiceAddress getSender() {
|
||||
public ServiceId getSender() {
|
||||
return sender;
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue