Remove E164s most places and prefer ServiceId more places.\

fork-5.53.8
Greyson Parrelli 2022-02-23 17:28:11 -05:00 zatwierdzone przez Alex Hart
rodzic d6b6884c69
commit 935dd7de45
50 zmienionych plików z 296 dodań i 304 usunięć

Wyświetl plik

@ -352,11 +352,11 @@ public final class ConversationUpdateItem extends FrameLayout
});
} else if (conversationMessage.getMessageRecord().isGroupCall()) {
UpdateDescription updateDescription = MessageRecord.getGroupCallUpdateDescription(getContext(), conversationMessage.getMessageRecord().getBody(), true);
Collection<ServiceId> acis = updateDescription.getMentioned();
Collection<ServiceId> sids = updateDescription.getMentioned();
int text = 0;
if (Util.hasItems(acis)) {
if (acis.contains(Recipient.self().requireServiceId())) {
if (Util.hasItems(sids)) {
if (sids.contains(SignalStore.account().requireAci())) {
text = R.string.ConversationUpdateItem_return_to_call;
} else if (GroupCallUpdateDetailsUtil.parse(conversationMessage.getMessageRecord().getBody()).getIsCallFull()) {
text = R.string.ConversationUpdateItem_call_is_full;

Wyświetl plik

@ -887,7 +887,7 @@ private static final String[] GROUP_PROJECTION = {
if (UuidUtil.UNKNOWN_UUID.equals(uuid)) {
Log.w(TAG, "Seen unknown UUID in members list");
} else {
RecipientId id = RecipientId.from(ACI.from(uuid), null);
RecipientId id = RecipientId.from(ServiceId.from(uuid), null);
Optional<RecipientId> remapped = RemappedRecords.getInstance().getRecipient(id);
if (remapped.isPresent()) {
@ -1319,7 +1319,7 @@ private static final String[] GROUP_PROJECTION = {
public List<RecipientId> getMemberRecipientIds(@NonNull MemberSet memberSet) {
boolean includeSelf = memberSet.includeSelf;
DecryptedGroup groupV2 = getDecryptedGroup();
UUID selfUuid = Recipient.self().requireServiceId().uuid();
UUID selfUuid = SignalStore.account().requireAci().uuid();
List<RecipientId> recipients = new ArrayList<>(groupV2.getMembersCount() + groupV2.getPendingMembersCount());
int unknownMembers = 0;
int unknownPending = 0;
@ -1328,7 +1328,7 @@ private static final String[] GROUP_PROJECTION = {
if (UuidUtil.UNKNOWN_UUID.equals(uuid)) {
unknownMembers++;
} else if (includeSelf || !selfUuid.equals(uuid)) {
recipients.add(RecipientId.from(ACI.from(uuid), null));
recipients.add(RecipientId.from(ServiceId.from(uuid), null));
}
}
if (memberSet.includePending) {
@ -1336,7 +1336,7 @@ private static final String[] GROUP_PROJECTION = {
if (UuidUtil.UNKNOWN_UUID.equals(uuid)) {
unknownPending++;
} else if (includeSelf || !selfUuid.equals(uuid)) {
recipients.add(RecipientId.from(ACI.from(uuid), null));
recipients.add(RecipientId.from(ServiceId.from(uuid), null));
}
}
}

Wyświetl plik

@ -18,7 +18,7 @@ import org.thoughtcrime.securesms.database.model.MessageRecord;
import org.thoughtcrime.securesms.database.model.databaseprotos.BodyRangeList;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import java.util.ArrayList;
import java.util.Collections;
@ -121,7 +121,7 @@ public final class MentionUtil {
return Stream.of(BodyRangeList.parseFrom(data).getRangesList())
.filter(bodyRange -> bodyRange.getAssociatedValueCase() == BodyRangeList.BodyRange.AssociatedValueCase.MENTIONUUID)
.map(mention -> {
RecipientId id = Recipient.externalPush(ACI.parseOrThrow(mention.getMentionUuid()), null, false).getId();
RecipientId id = Recipient.externalPush(ServiceId.parseOrThrow(mention.getMentionUuid()), null, false).getId();
return new Mention(id, mention.getStart(), mention.getLength());
})
.toList();

Wyświetl plik

@ -82,6 +82,7 @@ import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.libsignal.util.Pair;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import java.io.IOException;
import java.security.SecureRandom;
@ -1564,7 +1565,7 @@ public class MmsDatabase extends MessageDatabase {
MessageGroupContext.GroupV2Properties groupV2Properties = outgoingGroupUpdateMessage.requireGroupV2Properties();
members.addAll(Stream.of(groupV2Properties.getAllActivePendingAndRemovedMembers())
.distinct()
.map(uuid -> RecipientId.from(ACI.from(uuid), null))
.map(uuid -> RecipientId.from(ServiceId.from(uuid), null))
.toList());
members.remove(Recipient.self().getId());
} else {

Wyświetl plik

@ -1814,7 +1814,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
db.beginTransaction()
try {
val id = Recipient.self().id
val newId = getAndPossiblyMerge(Recipient.self().requireServiceId(), e164, highTrust = true, changeSelf = true)
val newId = getAndPossiblyMerge(SignalStore.account().requireAci(), e164, highTrust = true, changeSelf = true)
if (id == newId) {
Log.i(TAG, "[updateSelfPhone] Phone updated for self")
@ -2847,7 +2847,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
return RecipientRecord(
id = recipientId,
serviceId = ACI.parseOrNull(cursor.requireString(SERVICE_ID)),
serviceId = ServiceId.parseOrNull(cursor.requireString(SERVICE_ID)),
pni = PNI.parseOrNull(cursor.requireString(PNI_COLUMN)),
username = cursor.requireString(USERNAME),
e164 = cursor.requireString(PHONE),

Wyświetl plik

@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.whispersystems.libsignal.SignalProtocolAddress;
import org.whispersystems.signalservice.api.push.DistributionId;
@ -133,7 +134,7 @@ public class SenderKeyDatabase extends Database {
public Cursor getAllCreatedBySelf() {
SQLiteDatabase db = databaseHelper.getSignalReadableDatabase();
String query = ADDRESS + " = ?";
String[] args = SqlUtil.buildArgs(Recipient.self().requireServiceId());
String[] args = SqlUtil.buildArgs(SignalStore.account().requireAci());
return db.query(TABLE_NAME, new String[]{ ID, DISTRIBUTION_ID, CREATED_AT }, query, args, null, null, CREATED_AT + " DESC");
}

Wyświetl plik

@ -849,7 +849,7 @@ public class SmsDatabase extends MessageDatabase {
}
GroupCallUpdateDetails groupCallUpdateDetails = GroupCallUpdateDetailsUtil.parse(record.getBody());
boolean containsSelf = peekJoinedUuids.contains(Recipient.self().requireServiceId().uuid());
boolean containsSelf = peekJoinedUuids.contains(SignalStore.account().requireAci().uuid());
sameEraId = groupCallUpdateDetails.getEraId().equals(peekGroupCallEraId) && !Util.isEmpty(peekGroupCallEraId);

Wyświetl plik

@ -59,6 +59,7 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.storage.SignalAccountRecord;
import org.whispersystems.signalservice.api.storage.SignalContactRecord;
import org.whispersystems.signalservice.api.storage.SignalGroupV1Record;
@ -1470,7 +1471,7 @@ public class ThreadDatabase extends Database {
if (threadRecipient.isPushV2Group()) {
MessageRecord.InviteAddState inviteAddState = record.getGv2AddInviteState();
if (inviteAddState != null) {
RecipientId from = RecipientId.from(ACI.from(inviteAddState.getAddedOrInvitedBy()), null);
RecipientId from = RecipientId.from(ServiceId.from(inviteAddState.getAddedOrInvitedBy()), null);
if (inviteAddState.isInvited()) {
Log.i(TAG, "GV2 invite message request from " + from);
return Extra.forGroupV2invite(from, individualRecipientId);

Wyświetl plik

@ -253,7 +253,7 @@ public abstract class MessageRecord extends DisplayRecord {
private static boolean selfCreatedGroup(@NonNull DecryptedGroupChange change) {
return change.getRevision() == 0 &&
change.getEditor().equals(UuidUtil.toByteString(Recipient.self().requireServiceId().uuid()));
change.getEditor().equals(UuidUtil.toByteString(SignalStore.account().requireAci().uuid()));
}
public static @NonNull UpdateDescription getGv2ChangeDescription(@NonNull Context context, @NonNull String body) {
@ -261,7 +261,7 @@ public abstract class MessageRecord extends DisplayRecord {
ShortStringDescriptionStrategy descriptionStrategy = new ShortStringDescriptionStrategy(context);
byte[] decoded = Base64.decode(body);
DecryptedGroupV2Context decryptedGroupV2Context = DecryptedGroupV2Context.parseFrom(decoded);
GroupsV2UpdateMessageProducer updateMessageProducer = new GroupsV2UpdateMessageProducer(context, descriptionStrategy, Recipient.self().requireServiceId().uuid());
GroupsV2UpdateMessageProducer updateMessageProducer = new GroupsV2UpdateMessageProducer(context, descriptionStrategy, SignalStore.account().requireAci().uuid());
if (decryptedGroupV2Context.hasChange() && (decryptedGroupV2Context.getGroupState().getRevision() != 0 || decryptedGroupV2Context.hasPreviousGroupState())) {
return UpdateDescription.concatWithNewLines(updateMessageProducer.describeChanges(decryptedGroupV2Context.getPreviousGroupState(), decryptedGroupV2Context.getChange()));
@ -292,7 +292,7 @@ public abstract class MessageRecord extends DisplayRecord {
}
DecryptedGroup groupState = decryptedGroupV2Context.getGroupState();
boolean invited = DecryptedGroupUtil.findPendingByUuid(groupState.getPendingMembersList(), Recipient.self().requireServiceId().uuid()).isPresent();
boolean invited = DecryptedGroupUtil.findPendingByUuid(groupState.getPendingMembersList(), SignalStore.account().requireAci().uuid()).isPresent();
if (decryptedGroupV2Context.hasChange()) {
UUID changeEditor = UuidUtil.fromByteStringOrNull(decryptedGroupV2Context.getChange().getEditor());

Wyświetl plik

@ -62,6 +62,7 @@ import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations;
import org.whispersystems.signalservice.api.groupsv2.InvalidGroupStateException;
import org.whispersystems.signalservice.api.groupsv2.NotAbleToApplyGroupV2ChangeException;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
import org.whispersystems.signalservice.api.push.exceptions.ConflictException;
import org.whispersystems.signalservice.api.util.UuidUtil;
@ -1193,7 +1194,7 @@ final class GroupManagerV2 {
private static @NonNull List<RecipientId> getPendingMemberRecipientIds(@NonNull List<DecryptedPendingMember> newPendingMembersList) {
return Stream.of(DecryptedGroupUtil.pendingToUuidList(newPendingMembersList))
.map(uuid -> RecipientId.from(ACI.from(uuid), null))
.map(uuid -> RecipientId.from(ServiceId.from(uuid), null))
.toList();
}

Wyświetl plik

@ -86,7 +86,7 @@ public final class GroupProtoUtil {
@WorkerThread
public static Recipient uuidByteStringToRecipient(@NonNull Context context, @NonNull ByteString uuidByteString) {
ServiceId serviceId = ACI.fromByteString(uuidByteString);
ServiceId serviceId = ServiceId.fromByteString(uuidByteString);
if (serviceId.isUnknown()) {
return Recipient.UNKNOWN;
@ -97,7 +97,7 @@ public final class GroupProtoUtil {
@WorkerThread
public static @NonNull RecipientId uuidByteStringToRecipientId(@NonNull ByteString uuidByteString) {
ServiceId serviceId = ACI.fromByteString(uuidByteString);
ServiceId serviceId = ServiceId.fromByteString(uuidByteString);
if (serviceId.isUnknown()) {
return RecipientId.UNKNOWN;

Wyświetl plik

@ -21,6 +21,7 @@ import org.thoughtcrime.securesms.groups.GroupChangeException;
import org.thoughtcrime.securesms.groups.GroupId;
import org.thoughtcrime.securesms.groups.GroupManager;
import org.thoughtcrime.securesms.groups.GroupProtoUtil;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.recipients.Recipient;
import java.io.IOException;
@ -54,7 +55,7 @@ final class PendingMemberInvitesRepository {
List<DecryptedPendingMember> pendingMembersList = decryptedGroup.getPendingMembersList();
List<SinglePendingMemberInvitedByYou> byMe = new ArrayList<>(pendingMembersList.size());
List<MultiplePendingMembersInvitedByAnother> byOthers = new ArrayList<>(pendingMembersList.size());
ByteString self = Recipient.self().requireServiceId().toByteString();
ByteString self = SignalStore.account().requireAci().toByteString();
boolean selfIsAdmin = v2GroupProperties.isAdmin(Recipient.self());
Stream.of(pendingMembersList)

Wyświetl plik

@ -13,6 +13,7 @@ import org.signal.storageservice.protos.groups.local.DecryptedRequestingMember;
import org.signal.zkgroup.InvalidInputException;
import org.signal.zkgroup.profiles.ProfileKey;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.util.UuidUtil;
import java.util.LinkedHashMap;
@ -31,8 +32,8 @@ public final class ProfileKeySet {
private static final String TAG = Log.tag(ProfileKeySet.class);
private final Map<ACI, ProfileKey> profileKeys = new LinkedHashMap<>();
private final Map<ACI, ProfileKey> authoritativeProfileKeys = new LinkedHashMap<>();
private final Map<ServiceId, ProfileKey> profileKeys = new LinkedHashMap<>();
private final Map<ServiceId, ProfileKey> authoritativeProfileKeys = new LinkedHashMap<>();
/**
* Add new profile keys from a group change.
@ -97,20 +98,20 @@ public final class ProfileKeySet {
}
if (memberUuid.equals(changeSource)) {
authoritativeProfileKeys.put(ACI.from(memberUuid), profileKey);
profileKeys.remove(ACI.from(memberUuid));
authoritativeProfileKeys.put(ServiceId.from(memberUuid), profileKey);
profileKeys.remove(ServiceId.from(memberUuid));
} else {
if (!authoritativeProfileKeys.containsKey(ACI.from(memberUuid))) {
profileKeys.put(ACI.from(memberUuid), profileKey);
if (!authoritativeProfileKeys.containsKey(ServiceId.from(memberUuid))) {
profileKeys.put(ServiceId.from(memberUuid), profileKey);
}
}
}
public Map<ACI, ProfileKey> getProfileKeys() {
public Map<ServiceId, ProfileKey> getProfileKeys() {
return profileKeys;
}
public Map<ACI, ProfileKey> getAuthoritativeProfileKeys() {
public Map<ServiceId, ProfileKey> getAuthoritativeProfileKeys() {
return authoritativeProfileKeys;
}
}

Wyświetl plik

@ -53,6 +53,7 @@ import org.whispersystems.signalservice.api.groupsv2.InvalidGroupStateException;
import org.whispersystems.signalservice.api.groupsv2.NotAbleToApplyGroupV2ChangeException;
import org.whispersystems.signalservice.api.groupsv2.PartialDecryptedGroup;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.util.UuidUtil;
import org.whispersystems.signalservice.internal.push.exceptions.GroupNotFoundException;
import org.whispersystems.signalservice.internal.push.exceptions.NotInGroupException;
@ -579,7 +580,7 @@ public final class GroupsV2StateProcessor {
.filter(c -> c != null && c.getRevision() == revisionJoinedAt)
.findFirst()
.map(c -> Optional.fromNullable(UuidUtil.fromByteStringOrNull(c.getEditor()))
.transform(a -> Recipient.externalPush(ACI.fromByteStringOrNull(c.getEditor()), null, false)))
.transform(a -> Recipient.externalPush(ServiceId.fromByteStringOrNull(c.getEditor()), null, false)))
.orElse(Optional.absent());
if (addedByOptional.isPresent()) {
@ -650,7 +651,7 @@ public final class GroupsV2StateProcessor {
}
void storeMessage(@NonNull DecryptedGroupV2Context decryptedGroupV2Context, long timestamp) {
Optional<ACI> editor = getEditor(decryptedGroupV2Context).transform(ACI::from);
Optional<ServiceId> editor = getEditor(decryptedGroupV2Context).transform(ServiceId::from);
boolean outgoing = !editor.isPresent() || selfAci.equals(editor.get());

Wyświetl plik

@ -15,6 +15,7 @@ import org.thoughtcrime.securesms.database.RecipientDatabase;
import org.thoughtcrime.securesms.groups.GroupId;
import org.thoughtcrime.securesms.jobmanager.Data;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.messages.GroupSendUtil;
import org.thoughtcrime.securesms.mms.MessageGroupContext;
import org.thoughtcrime.securesms.mms.OutgoingGroupUpdateMessage;
@ -31,6 +32,7 @@ import org.whispersystems.signalservice.api.messages.SendMessageResult;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
import org.whispersystems.signalservice.api.messages.SignalServiceGroupV2;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.exceptions.ServerRejectedException;
import org.whispersystems.signalservice.api.util.UuidUtil;
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
@ -74,8 +76,8 @@ public final class PushGroupSilentUpdateSendJob extends BaseJob {
Set<RecipientId> recipients = Stream.concat(Stream.of(memberUuids), Stream.of(pendingUuids))
.filter(uuid -> !UuidUtil.UNKNOWN_UUID.equals(uuid))
.filter(uuid -> !Recipient.self().requireServiceId().uuid().equals(uuid))
.map(uuid -> Recipient.externalPush(ACI.from(uuid), null, false))
.filter(uuid -> !SignalStore.account().requireAci().uuid().equals(uuid))
.map(uuid -> Recipient.externalPush(ServiceId.from(uuid), null, false))
.filter(recipient -> recipient.getRegistered() != RecipientDatabase.RegisteredState.NOT_REGISTERED)
.map(Recipient::getId)
.collect(Collectors.toSet());

Wyświetl plik

@ -2200,7 +2200,7 @@ public final class MessageContentProcessor {
List<Mention> mentions = new ArrayList<>(signalServiceMentions.size());
for (SignalServiceDataMessage.Mention mention : signalServiceMentions) {
mentions.add(new Mention(Recipient.externalPush(mention.getAci(), null, false).getId(), mention.getStart(), mention.getLength()));
mentions.add(new Mention(Recipient.externalPush(mention.getServiceId(), null, false).getId(), mention.getStart(), mention.getLength()));
}
return mentions;

Wyświetl plik

@ -77,7 +77,7 @@ public final class MessageDecryptionUtil {
*/
public static @NonNull DecryptionResult decrypt(@NonNull Context context, @NonNull SignalServiceEnvelope envelope) {
SignalServiceAccountDataStore protocolStore = ApplicationDependencies.getProtocolStore().aci();
SignalServiceAddress localAddress = new SignalServiceAddress(Recipient.self().requireServiceId(), Recipient.self().requireE164());
SignalServiceAddress localAddress = new SignalServiceAddress(SignalStore.account().requireAci(), Recipient.self().requireE164());
SignalServiceCipher cipher = new SignalServiceCipher(localAddress, SignalStore.account().getDeviceId(), protocolStore, ReentrantSessionLock.INSTANCE, UnidentifiedAccessUtil.getCertificateValidator());
List<Job> jobs = new LinkedList<>();

Wyświetl plik

@ -48,7 +48,6 @@ import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.wallpaper.ChatWallpaper;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.libsignal.util.guava.Preconditions;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.PNI;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
@ -317,8 +316,8 @@ public class Recipient {
RecipientId id = null;
if (UuidUtil.isUuid(identifier)) {
ACI uuid = ACI.parseOrThrow(identifier);
id = db.getOrInsertFromServiceId(uuid);
ServiceId serviceId = ServiceId.parseOrThrow(identifier);
id = db.getOrInsertFromServiceId(serviceId);
} else if (GroupId.isEncodedGroup(identifier)) {
id = db.getOrInsertFromGroupId(GroupId.parseOrThrow(identifier));
} else if (NumberUtil.isValidEmail(identifier)) {

Wyświetl plik

@ -11,10 +11,8 @@ import androidx.annotation.Nullable;
import com.annimon.stream.Stream;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.util.DelimiterUtil;
import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.util.UuidUtil;
@ -66,7 +64,7 @@ public class RecipientId implements Parcelable, Comparable<RecipientId> {
@AnyThread
public static @NonNull RecipientId fromExternalPush(@NonNull String identifier) {
if (UuidUtil.isUuid(identifier)) {
return from(ACI.parseOrThrow(identifier), null);
return from(ServiceId.parseOrThrow(identifier), null);
} else {
return from(null, identifier);
}
@ -86,17 +84,17 @@ public class RecipientId implements Parcelable, Comparable<RecipientId> {
*/
@AnyThread
@SuppressLint("WrongThread")
public static @NonNull RecipientId from(@Nullable ServiceId aci, @Nullable String e164) {
return from(aci, e164, false);
public static @NonNull RecipientId from(@Nullable ServiceId serviceId, @Nullable String e164) {
return from(serviceId, e164, false);
}
@AnyThread
@SuppressLint("WrongThread")
private static @NonNull RecipientId from(@Nullable ServiceId aci, @Nullable String e164, boolean highTrust) {
RecipientId recipientId = RecipientIdCache.INSTANCE.get(aci, e164);
private static @NonNull RecipientId from(@Nullable ServiceId serviceId, @Nullable String e164, boolean highTrust) {
RecipientId recipientId = RecipientIdCache.INSTANCE.get(serviceId, e164);
if (recipientId == null) {
Recipient recipient = Recipient.externalPush(aci, e164, highTrust);
Recipient recipient = Recipient.externalPush(serviceId, e164, highTrust);
RecipientIdCache.INSTANCE.put(recipient);
recipientId = recipient.getId();
}

Wyświetl plik

@ -22,7 +22,7 @@ import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState;
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder;
import org.webrtc.VideoTrack;
import org.whispersystems.signalservice.api.messages.calls.OfferMessage;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import java.util.ArrayList;
import java.util.Collection;
@ -83,7 +83,7 @@ public class GroupActionProcessor extends DeviceAwareActionProcessor {
seen.add(Recipient.self());
for (GroupCall.RemoteDeviceState device : remoteDeviceStates) {
Recipient recipient = Recipient.externalPush(ACI.from(device.getUserId()), null, false);
Recipient recipient = Recipient.externalPush(ServiceId.from(device.getUserId()), null, false);
CallParticipantId callParticipantId = new CallParticipantId(device.getDemuxId(), recipient.getId());
CallParticipant callParticipant = participants.get(callParticipantId);

Wyświetl plik

@ -12,6 +12,7 @@ import org.signal.ringrtc.CallException;
import org.signal.ringrtc.GroupCall;
import org.signal.ringrtc.PeekInfo;
import org.thoughtcrime.securesms.events.WebRtcViewModel;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.ringrtc.Camera;
import org.thoughtcrime.securesms.ringrtc.RemotePeer;
@ -123,8 +124,8 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
webRtcInteractor.sendGroupCallMessage(currentState.getCallInfoState().getCallRecipient(), eraId);
List<UUID> members = new ArrayList<>(peekInfo.getJoinedMembers());
if (!members.contains(Recipient.self().requireServiceId().uuid())) {
members.add(Recipient.self().requireServiceId().uuid());
if (!members.contains(SignalStore.account().requireAci().uuid())) {
members.add(SignalStore.account().requireAci().uuid());
}
webRtcInteractor.updateGroupCallUpdateMessage(currentState.getCallInfoState().getCallRecipient().getId(), eraId, members, WebRtcUtil.isCallFull(peekInfo));

Wyświetl plik

@ -20,7 +20,7 @@ import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState;
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder;
import org.thoughtcrime.securesms.util.NetworkUtil;
import org.whispersystems.signalservice.api.messages.calls.OfferMessage;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import java.util.List;
@ -114,7 +114,7 @@ public class GroupPreJoinActionProcessor extends GroupActionProcessor {
}
List<Recipient> callParticipants = Stream.of(peekInfo.getJoinedMembers())
.map(uuid -> Recipient.externalPush(ACI.from(uuid), null, false))
.map(uuid -> Recipient.externalPush(ServiceId.from(uuid), null, false))
.toList();
WebRtcServiceStateBuilder.CallInfoStateBuilder builder = currentState.builder()

Wyświetl plik

@ -26,6 +26,7 @@ import org.thoughtcrime.securesms.util.NetworkUtil;
import org.thoughtcrime.securesms.webrtc.locks.LockManager;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import java.util.UUID;
@ -138,7 +139,7 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
.changeCallSetupState(RemotePeer.GROUP_CALL_ID)
.isRemoteVideoOffer(true)
.ringId(ringId)
.ringerRecipient(Recipient.externalPush(ACI.from(uuid), null, false))
.ringerRecipient(Recipient.externalPush(ServiceId.from(uuid), null, false))
.commit()
.changeCallInfoState()
.activePeer(new RemotePeer(currentState.getCallInfoState().getCallRecipient().getId(), RemotePeer.GROUP_CALL_ID))

Wyświetl plik

@ -65,7 +65,7 @@ import org.whispersystems.signalservice.api.messages.calls.OfferMessage;
import org.whispersystems.signalservice.api.messages.calls.OpaqueMessage;
import org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage;
import org.whispersystems.signalservice.api.messages.calls.TurnServerInfo;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
import java.io.IOException;
@ -154,7 +154,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
serviceExecutor.execute(() -> {
if (needsToSetSelfUuid) {
try {
callManager.setSelfUuid(Recipient.self().requireServiceId().uuid());
callManager.setSelfUuid(SignalStore.account().requireAci().uuid());
needsToSetSelfUuid = false;
} catch (CallException e) {
Log.w(TAG, "Unable to set self UUID on CallManager", e);
@ -618,7 +618,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forOpaque(opaqueMessage, true, null);
networkExecutor.execute(() -> {
Recipient recipient = Recipient.resolved(RecipientId.from(ACI.from(uuid), null));
Recipient recipient = Recipient.resolved(RecipientId.from(ServiceId.from(uuid), null));
if (recipient.isBlocked()) {
return;
}

Wyświetl plik

@ -1,6 +1,5 @@
package org.thoughtcrime.securesms.util;
import android.content.Context;
import android.text.TextUtils;
import androidx.annotation.NonNull;
@ -14,7 +13,6 @@ import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import java.io.IOException;
@ -70,7 +68,7 @@ public class UsernameUtil {
try {
Log.d(TAG, "No local user with this username. Searching remotely.");
SignalServiceProfile profile = ApplicationDependencies.getSignalServiceMessageReceiver().retrieveProfileByUsername(username, Optional.absent(), Locale.getDefault());
return Optional.fromNullable(profile.getAci());
return Optional.fromNullable(profile.getServiceId());
} catch (IOException e) {
return Optional.absent();
}

Wyświetl plik

@ -49,6 +49,7 @@ import org.thoughtcrime.securesms.crypto.ReentrantSessionLock;
import org.thoughtcrime.securesms.database.IdentityDatabase;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.jobs.MultiDeviceVerifiedUpdateJob;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.qr.QrCode;
import org.thoughtcrime.securesms.recipients.LiveRecipient;
import org.thoughtcrime.securesms.recipients.Recipient;
@ -213,7 +214,7 @@ public class VerifyDisplayFragment extends Fragment implements ViewTreeObserver.
if (FeatureFlags.verifyV2() && resolved.getServiceId().isPresent()) {
Log.i(TAG, "Using UUID (version 2).");
version = 2;
localId = Recipient.self().requireServiceId().toByteArray();
localId = SignalStore.account().requireAci().toByteArray();
remoteId = resolved.requireServiceId().toByteArray();
} else if (!FeatureFlags.verifyV2() && resolved.getE164().isPresent()) {
Log.i(TAG, "Using E164 (version 1).");

Wyświetl plik

@ -4,7 +4,6 @@ import org.junit.Test;
import org.thoughtcrime.securesms.contacts.sync.FuzzyPhoneNumberHelper.InputResult;
import org.thoughtcrime.securesms.contacts.sync.FuzzyPhoneNumberHelper.OutputResult;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.util.UuidUtil;
import java.util.Arrays;
import java.util.Collections;

Wyświetl plik

@ -17,8 +17,8 @@ import org.thoughtcrime.securesms.recipients.RecipientId
import org.whispersystems.libsignal.util.guava.Optional
import org.whispersystems.signalservice.api.groupsv2.DecryptedGroupHistoryEntry
import org.whispersystems.signalservice.api.groupsv2.GroupHistoryPage
import org.whispersystems.signalservice.api.push.ACI
import org.whispersystems.signalservice.api.push.DistributionId
import org.whispersystems.signalservice.api.push.ServiceId
import java.util.UUID
fun DecryptedGroupChange.Builder.setNewDescription(description: String) {
@ -190,20 +190,20 @@ fun decryptedGroup(
return builder.build()
}
fun member(aci: UUID, role: Member.Role = Member.Role.DEFAULT, joinedAt: Int = 0): DecryptedMember {
return member(ACI.from(aci), role, joinedAt)
fun member(serviceId: UUID, role: Member.Role = Member.Role.DEFAULT, joinedAt: Int = 0): DecryptedMember {
return member(ServiceId.from(serviceId), role, joinedAt)
}
fun member(aci: ACI, role: Member.Role = Member.Role.DEFAULT, joinedAt: Int = 0): DecryptedMember {
fun member(serviceId: ServiceId, role: Member.Role = Member.Role.DEFAULT, joinedAt: Int = 0): DecryptedMember {
return DecryptedMember.newBuilder()
.setRole(role)
.setUuid(aci.toByteString())
.setUuid(serviceId.toByteString())
.setJoinedAtRevision(joinedAt)
.build()
}
fun requestingMember(aci: ACI): DecryptedRequestingMember {
fun requestingMember(serviceId: ServiceId): DecryptedRequestingMember {
return DecryptedRequestingMember.newBuilder()
.setUuid(aci.toByteString())
.setUuid(serviceId.toByteString())
.build()
}

Wyświetl plik

@ -14,7 +14,7 @@ import org.thoughtcrime.securesms.recipients.RecipientId
import org.thoughtcrime.securesms.util.Bitmask
import org.thoughtcrime.securesms.wallpaper.ChatWallpaper
import org.whispersystems.libsignal.util.guava.Optional
import org.whispersystems.signalservice.api.push.ACI
import org.whispersystems.signalservice.api.push.ServiceId
import java.util.UUID
import kotlin.random.Random
@ -31,7 +31,7 @@ object RecipientDatabaseTestUtils {
isSelf: Boolean = false,
participants: List<Recipient> = listOf(),
recipientId: RecipientId = RecipientId.from(Random.nextLong()),
aci: ACI? = ACI.from(UUID.randomUUID()),
serviceId: ServiceId? = ServiceId.from(UUID.randomUUID()),
username: String? = null,
e164: String? = null,
email: String? = null,
@ -93,7 +93,7 @@ object RecipientDatabaseTestUtils {
registered,
RecipientRecord(
recipientId,
aci,
serviceId,
null,
username,
e164,

Wyświetl plik

@ -7,6 +7,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.signal.core.util.ThreadUtil;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import java.util.Arrays;
import java.util.Collections;
@ -51,7 +52,7 @@ public final class UpdateDescriptionTest {
@Test(expected = AssertionError.class)
public void stringFactory_cannot_run_on_main_thread() {
UpdateDescription description = UpdateDescription.mentioning(Collections.singletonList(ACI.from(UUID.randomUUID())), () -> "update", 0);
UpdateDescription description = UpdateDescription.mentioning(Collections.singletonList(ServiceId.from(UUID.randomUUID())), () -> "update", 0);
setMainThread(true);
@ -60,7 +61,7 @@ public final class UpdateDescriptionTest {
@Test(expected = UnsupportedOperationException.class)
public void stringFactory_cannot_call_static_string() {
UpdateDescription description = UpdateDescription.mentioning(Collections.singletonList(ACI.from(UUID.randomUUID())), () -> "update", 0);
UpdateDescription description = UpdateDescription.mentioning(Collections.singletonList(ServiceId.from(UUID.randomUUID())), () -> "update", 0);
description.getStaticString();
}
@ -74,7 +75,7 @@ public final class UpdateDescriptionTest {
return "update";
};
UpdateDescription description = UpdateDescription.mentioning(Collections.singletonList(ACI.from(UUID.randomUUID())), stringFactory, 0);
UpdateDescription description = UpdateDescription.mentioning(Collections.singletonList(ServiceId.from(UUID.randomUUID())), stringFactory, 0);
assertEquals(0, factoryCalls.get());
@ -90,7 +91,7 @@ public final class UpdateDescriptionTest {
public void stringFactory_reevaluated_on_every_call() {
AtomicInteger factoryCalls = new AtomicInteger();
UpdateDescription.StringFactory stringFactory = () -> "call" + factoryCalls.incrementAndGet();
UpdateDescription description = UpdateDescription.mentioning(Collections.singletonList(ACI.from(UUID.randomUUID())), stringFactory, 0);
UpdateDescription description = UpdateDescription.mentioning(Collections.singletonList(ServiceId.from(UUID.randomUUID())), stringFactory, 0);
setMainThread(false);
@ -126,8 +127,8 @@ public final class UpdateDescriptionTest {
AtomicInteger factoryCalls2 = new AtomicInteger();
UpdateDescription.StringFactory stringFactory1 = () -> "update." + factoryCalls1.incrementAndGet();
UpdateDescription.StringFactory stringFactory2 = () -> "update." + factoryCalls2.incrementAndGet();
UpdateDescription description1 = UpdateDescription.mentioning(Collections.singletonList(ACI.from(UUID.randomUUID())), stringFactory1, 0);
UpdateDescription description2 = UpdateDescription.mentioning(Collections.singletonList(ACI.from(UUID.randomUUID())), stringFactory2, 0);
UpdateDescription description1 = UpdateDescription.mentioning(Collections.singletonList(ServiceId.from(UUID.randomUUID())), stringFactory1, 0);
UpdateDescription description2 = UpdateDescription.mentioning(Collections.singletonList(ServiceId.from(UUID.randomUUID())), stringFactory2, 0);
factoryCalls1.set(10);
factoryCalls2.set(20);
@ -149,9 +150,9 @@ public final class UpdateDescriptionTest {
AtomicInteger factoryCalls2 = new AtomicInteger();
UpdateDescription.StringFactory stringFactory1 = () -> "update." + factoryCalls1.incrementAndGet();
UpdateDescription.StringFactory stringFactory2 = () -> "update." + factoryCalls2.incrementAndGet();
UpdateDescription description1 = UpdateDescription.mentioning(Collections.singletonList(ACI.from(UUID.randomUUID())), stringFactory1, 0);
UpdateDescription description1 = UpdateDescription.mentioning(Collections.singletonList(ServiceId.from(UUID.randomUUID())), stringFactory1, 0);
UpdateDescription description2 = UpdateDescription.staticDescription("static", 0);
UpdateDescription description3 = UpdateDescription.mentioning(Collections.singletonList(ACI.from(UUID.randomUUID())), stringFactory2, 0);
UpdateDescription description3 = UpdateDescription.mentioning(Collections.singletonList(ServiceId.from(UUID.randomUUID())), stringFactory2, 0);
factoryCalls1.set(100);
factoryCalls2.set(200);

Wyświetl plik

@ -6,6 +6,7 @@ import org.signal.zkgroup.profiles.ProfileKey;
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
import org.thoughtcrime.securesms.testutil.LogRecorder;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import java.util.Collections;
import java.util.UUID;
@ -40,7 +41,7 @@ public final class ProfileKeySetTest {
profileKeySet.addKeysFromGroupChange(changeBy(editor).addMember(newMember, profileKey).build());
assertTrue(profileKeySet.getAuthoritativeProfileKeys().isEmpty());
assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ACI.from(newMember), profileKey)));
assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ServiceId.from(newMember), profileKey)));
}
@Test
@ -52,7 +53,7 @@ public final class ProfileKeySetTest {
profileKeySet.addKeysFromGroupChange(changeBy(newMember).addMember(newMember, profileKey).build());
assertTrue(profileKeySet.getProfileKeys().isEmpty());
assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ACI.from(newMember), profileKey)));
assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ServiceId.from(newMember), profileKey)));
}
@Test
@ -64,7 +65,7 @@ public final class ProfileKeySetTest {
profileKeySet.addKeysFromGroupChange(changeBy(newMember).promote(newMember, profileKey).build());
assertTrue(profileKeySet.getProfileKeys().isEmpty());
assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ACI.from(newMember), profileKey)));
assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ServiceId.from(newMember), profileKey)));
}
@Test
@ -77,7 +78,7 @@ public final class ProfileKeySetTest {
profileKeySet.addKeysFromGroupChange(changeBy(editor).promote(newMember, profileKey).build());
assertTrue(profileKeySet.getAuthoritativeProfileKeys().isEmpty());
assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ACI.from(newMember), profileKey)));
assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ServiceId.from(newMember), profileKey)));
}
@Test
@ -89,7 +90,7 @@ public final class ProfileKeySetTest {
profileKeySet.addKeysFromGroupChange(changeByUnknown().promote(newMember, profileKey).build());
assertTrue(profileKeySet.getAuthoritativeProfileKeys().isEmpty());
assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ACI.from(newMember), profileKey)));
assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ServiceId.from(newMember), profileKey)));
}
@Test
@ -101,7 +102,7 @@ public final class ProfileKeySetTest {
profileKeySet.addKeysFromGroupChange(changeBy(member).profileKeyUpdate(member, profileKey).build());
assertTrue(profileKeySet.getProfileKeys().isEmpty());
assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ACI.from(member), profileKey)));
assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ServiceId.from(member), profileKey)));
}
@Test
@ -114,7 +115,7 @@ public final class ProfileKeySetTest {
profileKeySet.addKeysFromGroupChange(changeBy(editor).profileKeyUpdate(member, profileKey).build());
assertTrue(profileKeySet.getAuthoritativeProfileKeys().isEmpty());
assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ACI.from(member), profileKey)));
assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ServiceId.from(member), profileKey)));
}
@Test
@ -129,7 +130,7 @@ public final class ProfileKeySetTest {
profileKeySet.addKeysFromGroupChange(changeBy(editor).profileKeyUpdate(member, profileKey2).build());
assertTrue(profileKeySet.getAuthoritativeProfileKeys().isEmpty());
assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ACI.from(member), profileKey2)));
assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ServiceId.from(member), profileKey2)));
}
@Test
@ -144,7 +145,7 @@ public final class ProfileKeySetTest {
profileKeySet.addKeysFromGroupChange(changeBy(editor).profileKeyUpdate(member, profileKey2).build());
assertTrue(profileKeySet.getProfileKeys().isEmpty());
assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ACI.from(member), profileKey1)));
assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ServiceId.from(member), profileKey1)));
}
@Test
@ -159,7 +160,7 @@ public final class ProfileKeySetTest {
profileKeySet.addKeysFromGroupChange(changeBy(member).profileKeyUpdate(member, profileKey2).build());
assertTrue(profileKeySet.getProfileKeys().isEmpty());
assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ACI.from(member), profileKey2)));
assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ServiceId.from(member), profileKey2)));
}
@Test
@ -186,7 +187,7 @@ public final class ProfileKeySetTest {
profileKeySet.addKeysFromGroupChange(changeBy(editor).requestJoin(profileKey).build());
assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ACI.from(editor), profileKey)));
assertThat(profileKeySet.getAuthoritativeProfileKeys(), is(Collections.singletonMap(ServiceId.from(editor), profileKey)));
assertTrue(profileKeySet.getProfileKeys().isEmpty());
}
@ -200,6 +201,6 @@ public final class ProfileKeySetTest {
profileKeySet.addKeysFromGroupChange(changeBy(editor).requestJoin(requesting, profileKey).build());
assertTrue(profileKeySet.getAuthoritativeProfileKeys().isEmpty());
assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ACI.from(requesting), profileKey)));
assertThat(profileKeySet.getProfileKeys(), is(Collections.singletonMap(ServiceId.from(requesting), profileKey)));
}
}

Wyświetl plik

@ -43,6 +43,7 @@ import org.whispersystems.libsignal.logging.SignalProtocolLoggerProvider
import org.whispersystems.signalservice.api.groupsv2.GroupsV2Api
import org.whispersystems.signalservice.api.groupsv2.PartialDecryptedGroup
import org.whispersystems.signalservice.api.push.ACI
import org.whispersystems.signalservice.api.push.ServiceId
import java.util.UUID
@RunWith(RobolectricTestRunner::class)
@ -52,9 +53,9 @@ class GroupsV2StateProcessorTest {
companion object {
val masterKey = GroupMasterKey(fromStringCondensed("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"))
val selfAci: ACI = ACI.from(UUID.randomUUID())
val otherAci: ACI = ACI.from(UUID.randomUUID())
val selfAndOthers: List<DecryptedMember> = listOf(member(selfAci), member(otherAci))
val others: List<DecryptedMember> = listOf(member(otherAci))
val otherSid: ServiceId = ServiceId.from(UUID.randomUUID())
val selfAndOthers: List<DecryptedMember> = listOf(member(selfAci), member(otherSid))
val others: List<DecryptedMember> = listOf(member(otherSid))
}
private lateinit var groupDatabase: GroupDatabase
@ -248,7 +249,7 @@ class GroupsV2StateProcessorTest {
revision = 2,
title = "Breaking Signal for Science",
description = "We break stuff, because we must.",
members = listOf(member(otherAci), member(selfAci, joinedAt = 2))
members = listOf(member(otherSid), member(selfAci, joinedAt = 2))
)
changeSet {
changeLog(2) {
@ -270,7 +271,7 @@ class GroupsV2StateProcessorTest {
revision = 3,
title = "Breaking Signal for Science",
description = "We break stuff, because we must.",
members = listOf(member(otherAci), member(selfAci, joinedAt = 2))
members = listOf(member(otherSid), member(selfAci, joinedAt = 2))
)
changeSet {
changeLog(2) {
@ -327,7 +328,7 @@ class GroupsV2StateProcessorTest {
serverState(
revision = 3,
title = "Beam me up",
members = listOf(member(otherAci), member(selfAci, joinedAt = 3))
members = listOf(member(otherSid), member(selfAci, joinedAt = 3))
)
changeSet {
changeLog(3) {
@ -357,7 +358,7 @@ class GroupsV2StateProcessorTest {
serverState(
revision = 5,
title = "Beam me up!",
members = listOf(member(otherAci), member(selfAci, joinedAt = 3))
members = listOf(member(otherSid), member(selfAci, joinedAt = 3))
)
changeSet {
changeLog(3) {

Wyświetl plik

@ -9,6 +9,7 @@ import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.testutil.LogRecorder;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import java.util.UUID;
@ -40,7 +41,7 @@ public final class RecipientIdCacheTest {
@Test
public void empty_access_by_uuid() {
RecipientId recipientId = recipientIdCache.get(ACI.from(UUID.randomUUID()), null);
RecipientId recipientId = recipientIdCache.get(ServiceId.from(UUID.randomUUID()), null);
assertNull(recipientId);
}
@ -55,11 +56,11 @@ public final class RecipientIdCacheTest {
@Test
public void cache_hit_by_uuid() {
RecipientId recipientId1 = recipientId();
ACI aci1 = ACI.from(UUID.randomUUID());
ServiceId sid1 = ServiceId.from(UUID.randomUUID());
recipientIdCache.put(recipient(recipientId1, aci1, null));
recipientIdCache.put(recipient(recipientId1, sid1, null));
RecipientId recipientId = recipientIdCache.get(aci1, null);
RecipientId recipientId = recipientIdCache.get(sid1, null);
assertEquals(recipientId1, recipientId);
}
@ -67,12 +68,12 @@ public final class RecipientIdCacheTest {
@Test
public void cache_miss_by_uuid() {
RecipientId recipientId1 = recipientId();
ACI aci1 = ACI.from(UUID.randomUUID());
ACI aci2 = ACI.from(UUID.randomUUID());
ServiceId sid1 = ServiceId.from(UUID.randomUUID());
ServiceId sid2 = ServiceId.from(UUID.randomUUID());
recipientIdCache.put(recipient(recipientId1, aci1, null));
recipientIdCache.put(recipient(recipientId1, sid1, null));
RecipientId recipientId = recipientIdCache.get(aci2, null);
RecipientId recipientId = recipientIdCache.get(sid2, null);
assertNull(recipientId);
}
@ -80,11 +81,11 @@ public final class RecipientIdCacheTest {
@Test
public void cache_hit_by_uuid_e164_not_supplied_on_get() {
RecipientId recipientId1 = recipientId();
ACI aci1 = ACI.from(UUID.randomUUID());
ServiceId sid1 = ServiceId.from(UUID.randomUUID());
recipientIdCache.put(recipient(recipientId1, aci1, "+15551234567"));
recipientIdCache.put(recipient(recipientId1, sid1, "+15551234567"));
RecipientId recipientId = recipientIdCache.get(aci1, null);
RecipientId recipientId = recipientIdCache.get(sid1, null);
assertEquals(recipientId1, recipientId);
}
@ -92,11 +93,11 @@ public final class RecipientIdCacheTest {
@Test
public void cache_miss_by_uuid_e164_not_supplied_on_put() {
RecipientId recipientId1 = recipientId();
ACI aci1 = ACI.from(UUID.randomUUID());
ServiceId sid1 = ServiceId.from(UUID.randomUUID());
recipientIdCache.put(recipient(recipientId1, aci1, null));
recipientIdCache.put(recipient(recipientId1, sid1, null));
RecipientId recipientId = recipientIdCache.get(aci1, "+15551234567");
RecipientId recipientId = recipientIdCache.get(sid1, "+15551234567");
assertNull(recipientId);
}
@ -129,9 +130,9 @@ public final class RecipientIdCacheTest {
@Test
public void cache_hit_by_e164_uuid_not_supplied_on_get() {
RecipientId recipientId1 = recipientId();
ACI aci1 = ACI.from(UUID.randomUUID());
ServiceId sid1 = ServiceId.from(UUID.randomUUID());
recipientIdCache.put(recipient(recipientId1, aci1, "+15551234567"));
recipientIdCache.put(recipient(recipientId1, sid1, "+15551234567"));
RecipientId recipientId = recipientIdCache.get(null, "+15551234567");
@ -141,12 +142,12 @@ public final class RecipientIdCacheTest {
@Test
public void cache_miss_by_e164_uuid_not_supplied_on_put() {
RecipientId recipientId1 = recipientId();
ACI aci1 = ACI.from(UUID.randomUUID());
ServiceId sid1 = ServiceId.from(UUID.randomUUID());
String e164 = "+1555123456";
recipientIdCache.put(recipient(recipientId1, null, e164));
RecipientId recipientId = recipientIdCache.get(aci1, e164);
RecipientId recipientId = recipientIdCache.get(sid1, e164);
assertNull(recipientId);
}
@ -154,12 +155,12 @@ public final class RecipientIdCacheTest {
@Test
public void cache_hit_by_both() {
RecipientId recipientId1 = recipientId();
ACI aci1 = ACI.from(UUID.randomUUID());
ServiceId sid1 = ServiceId.from(UUID.randomUUID());
String e164 = "+1555123456";
recipientIdCache.put(recipient(recipientId1, aci1, e164));
recipientIdCache.put(recipient(recipientId1, sid1, e164));
RecipientId recipientId = recipientIdCache.get(aci1, e164);
RecipientId recipientId = recipientIdCache.get(sid1, e164);
assertEquals(recipientId1, recipientId);
}
@ -167,13 +168,13 @@ public final class RecipientIdCacheTest {
@Test
public void full_recipient_id_learned_by_two_puts() {
RecipientId recipientId1 = recipientId();
ACI aci1 = ACI.from(UUID.randomUUID());
ServiceId sid1 = ServiceId.from(UUID.randomUUID());
String e164 = "+1555123456";
recipientIdCache.put(recipient(recipientId1, aci1, null));
recipientIdCache.put(recipient(recipientId1, sid1, null));
recipientIdCache.put(recipient(recipientId1, null, e164));
RecipientId recipientId = recipientIdCache.get(aci1, e164);
RecipientId recipientId = recipientIdCache.get(sid1, e164);
assertEquals(recipientId1, recipientId);
}
@ -182,13 +183,13 @@ public final class RecipientIdCacheTest {
public void if_cache_state_disagrees_returns_null() {
RecipientId recipientId1 = recipientId();
RecipientId recipientId2 = recipientId();
ACI aci = ACI.from(UUID.randomUUID());
ServiceId sid = ServiceId.from(UUID.randomUUID());
String e164 = "+1555123456";
recipientIdCache.put(recipient(recipientId1, null, e164));
recipientIdCache.put(recipient(recipientId2, aci, null));
recipientIdCache.put(recipient(recipientId2, sid, null));
RecipientId recipientId = recipientIdCache.get(aci, e164);
RecipientId recipientId = recipientIdCache.get(sid, e164);
assertNull(recipientId);
@ -200,15 +201,15 @@ public final class RecipientIdCacheTest {
public void after_invalid_cache_hit_entries_are_cleared_up() {
RecipientId recipientId1 = recipientId();
RecipientId recipientId2 = recipientId();
ACI aci = ACI.from(UUID.randomUUID());
ServiceId sid = ServiceId.from(UUID.randomUUID());
String e164 = "+1555123456";
recipientIdCache.put(recipient(recipientId1, null, e164));
recipientIdCache.put(recipient(recipientId2, aci, null));
recipientIdCache.put(recipient(recipientId2, sid, null));
recipientIdCache.get(aci, e164);
recipientIdCache.get(sid, e164);
assertNull(recipientIdCache.get(aci, null));
assertNull(recipientIdCache.get(sid, null));
assertNull(recipientIdCache.get(null, e164));
}
@ -216,57 +217,57 @@ public final class RecipientIdCacheTest {
public void multiple_entries() {
RecipientId recipientId1 = recipientId();
RecipientId recipientId2 = recipientId();
ACI aci1 = ACI.from(UUID.randomUUID());
ACI aci2 = ACI.from(UUID.randomUUID());
ServiceId sid1 = ServiceId.from(UUID.randomUUID());
ServiceId sid2 = ServiceId.from(UUID.randomUUID());
recipientIdCache.put(recipient(recipientId1, aci1, null));
recipientIdCache.put(recipient(recipientId2, aci2, null));
recipientIdCache.put(recipient(recipientId1, sid1, null));
recipientIdCache.put(recipient(recipientId2, sid2, null));
assertEquals(recipientId1, recipientIdCache.get(aci1, null));
assertEquals(recipientId2, recipientIdCache.get(aci2, null));
assertEquals(recipientId1, recipientIdCache.get(sid1, null));
assertEquals(recipientId2, recipientIdCache.get(sid2, null));
}
@Test
public void drops_oldest_when_reaches_cache_limit() {
RecipientId recipientId1 = recipientId();
ACI aci1 = ACI.from(UUID.randomUUID());
ServiceId sid1 = ServiceId.from(UUID.randomUUID());
recipientIdCache.put(recipient(recipientId1, aci1, null));
recipientIdCache.put(recipient(recipientId1, sid1, null));
for (int i = 0; i < TEST_CACHE_LIMIT; i++) {
recipientIdCache.put(recipient(recipientId(), ACI.from(UUID.randomUUID()), null));
recipientIdCache.put(recipient(recipientId(), ServiceId.from(UUID.randomUUID()), null));
}
assertNull(recipientIdCache.get(aci1, null));
assertNull(recipientIdCache.get(sid1, null));
}
@Test
public void remains_in_cache_when_used_before_reaching_cache_limit() {
RecipientId recipientId1 = recipientId();
ACI aci1 = ACI.from(UUID.randomUUID());
ServiceId sid1 = ServiceId.from(UUID.randomUUID());
recipientIdCache.put(recipient(recipientId1, aci1, null));
recipientIdCache.put(recipient(recipientId1, sid1, null));
for (int i = 0; i < TEST_CACHE_LIMIT - 1; i++) {
recipientIdCache.put(recipient(recipientId(), ACI.from(UUID.randomUUID()), null));
recipientIdCache.put(recipient(recipientId(), ServiceId.from(UUID.randomUUID()), null));
}
assertEquals(recipientId1, recipientIdCache.get(aci1, null));
assertEquals(recipientId1, recipientIdCache.get(sid1, null));
recipientIdCache.put(recipient(recipientId(), ACI.from(UUID.randomUUID()), null));
recipientIdCache.put(recipient(recipientId(), ServiceId.from(UUID.randomUUID()), null));
assertEquals(recipientId1, recipientIdCache.get(aci1, null));
assertEquals(recipientId1, recipientIdCache.get(sid1, null));
}
private static @NonNull RecipientId recipientId() {
return mock(RecipientId.class);
}
private static @NonNull Recipient recipient(RecipientId recipientId, @Nullable ACI aci, @Nullable String e164) {
private static @NonNull Recipient recipient(RecipientId recipientId, @Nullable ServiceId serviceId, @Nullable String e164) {
Recipient mock = mock(Recipient.class);
when(mock.getId()).thenReturn(recipientId);
when(mock.getServiceId()).thenReturn(Optional.fromNullable(aci));
when(mock.getServiceId()).thenReturn(Optional.fromNullable(serviceId));
when(mock.getE164()).thenReturn(Optional.fromNullable(e164));
return mock;

Wyświetl plik

@ -15,7 +15,7 @@ import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.storage.StorageSyncHelper.IdDifferenceResult;
import org.thoughtcrime.securesms.util.FeatureFlags;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.storage.SignalAccountRecord;
import org.whispersystems.signalservice.api.storage.SignalContactRecord;
@ -47,15 +47,15 @@ import static org.thoughtcrime.securesms.testutil.TestHelpers.byteListOf;
@PowerMockRunnerDelegate(JUnit4.class)
public final class StorageSyncHelperTest {
private static final ACI ACI_A = ACI.parseOrThrow("ebef429e-695e-4f51-bcc4-526a60ac68c7");
private static final ACI ACI_SELF = ACI.parseOrThrow("1b2a2ca5-fc9e-4656-8c9f-22cc349ed3af");
private static final ServiceId SID_A = ServiceId.parseOrThrow("ebef429e-695e-4f51-bcc4-526a60ac68c7");
private static final ServiceId SID_SELF = ServiceId.parseOrThrow("1b2a2ca5-fc9e-4656-8c9f-22cc349ed3af");
private static final String E164_A = "+16108675309";
private static final String E164_SELF = "+16105555555";
private static final Recipient SELF = mock(Recipient.class);
static {
when(SELF.getServiceId()).thenReturn(Optional.of(ACI_SELF));
when(SELF.getServiceId()).thenReturn(Optional.of(SID_SELF));
when(SELF.getE164()).thenReturn(Optional.of(E164_SELF));
when(SELF.resolve()).thenReturn(SELF);
}
@ -132,8 +132,8 @@ public final class StorageSyncHelperTest {
byte[] profileKey = new byte[32];
byte[] profileKeyCopy = profileKey.clone();
SignalContactRecord a = contactBuilder(1, ACI_A, E164_A, "a").setProfileKey(profileKey).build();
SignalContactRecord b = contactBuilder(1, ACI_A, E164_A, "a").setProfileKey(profileKeyCopy).build();
SignalContactRecord a = contactBuilder(1, SID_A, E164_A, "a").setProfileKey(profileKey).build();
SignalContactRecord b = contactBuilder(1, SID_A, E164_A, "a").setProfileKey(profileKeyCopy).build();
assertEquals(a, b);
assertEquals(a.hashCode(), b.hashCode());
@ -147,8 +147,8 @@ public final class StorageSyncHelperTest {
byte[] profileKeyCopy = profileKey.clone();
profileKeyCopy[0] = 1;
SignalContactRecord a = contactBuilder(1, ACI_A, E164_A, "a").setProfileKey(profileKey).build();
SignalContactRecord b = contactBuilder(1, ACI_A, E164_A, "a").setProfileKey(profileKeyCopy).build();
SignalContactRecord a = contactBuilder(1, SID_A, E164_A, "a").setProfileKey(profileKey).build();
SignalContactRecord b = contactBuilder(1, SID_A, E164_A, "a").setProfileKey(profileKeyCopy).build();
assertNotEquals(a, b);
assertNotEquals(a.hashCode(), b.hashCode());
@ -171,7 +171,7 @@ public final class StorageSyncHelperTest {
}
private static SignalContactRecord.Builder contactBuilder(int key,
ACI aci,
ServiceId aci,
String e164,
String profileName)
{

Wyświetl plik

@ -20,7 +20,6 @@ import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
import org.whispersystems.signalservice.api.messages.SignalServiceStickerManifest;
import org.whispersystems.signalservice.api.profiles.ProfileAndCredential;
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.push.exceptions.MissingConfigurationException;
@ -204,7 +203,7 @@ public class SignalServiceMessageReceiver {
SignalServiceEnvelope envelope;
if (entity.hasSource() && entity.getSourceDevice() > 0) {
SignalServiceAddress address = new SignalServiceAddress(ACI.parseOrThrow(entity.getSourceUuid()), entity.getSourceE164());
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(entity.getSourceUuid()), entity.getSourceE164());
envelope = new SignalServiceEnvelope(entity.getType(),
Optional.of(address),
entity.getSourceDevice(),

Wyświetl plik

@ -802,7 +802,7 @@ public class SignalServiceMessageSender {
quoteBuilder.addBodyRanges(DataMessage.BodyRange.newBuilder()
.setStart(mention.getStart())
.setLength(mention.getLength())
.setMentionUuid(mention.getAci().toString()));
.setMentionUuid(mention.getServiceId().toString()));
}
builder.setRequiredProtocolVersion(Math.max(DataMessage.ProtocolVersion.MENTIONS_VALUE, builder.getRequiredProtocolVersion()));
@ -856,7 +856,7 @@ public class SignalServiceMessageSender {
builder.addBodyRanges(DataMessage.BodyRange.newBuilder()
.setStart(mention.getStart())
.setLength(mention.getLength())
.setMentionUuid(mention.getAci().toString()));
.setMentionUuid(mention.getServiceId().toString()));
}
builder.setRequiredProtocolVersion(Math.max(DataMessage.ProtocolVersion.MENTIONS_VALUE, builder.getRequiredProtocolVersion()));
}
@ -927,7 +927,7 @@ public class SignalServiceMessageSender {
SignalServiceDataMessage.StoryContext storyContext = message.getStoryContext().get();
builder.setStoryContext(DataMessage.StoryContext.newBuilder()
.setAuthorUuid(storyContext.getAuthorAci().toString())
.setAuthorUuid(storyContext.getAuthorServiceId().toString())
.setSentTimestamp(storyContext.getSentTimestamp()));
}
@ -1069,26 +1069,16 @@ public class SignalServiceMessageSender {
for (SendMessageResult result : sendMessageResults) {
if (result.getSuccess() != null) {
SyncMessage.Sent.UnidentifiedDeliveryStatus.Builder builder = SyncMessage.Sent.UnidentifiedDeliveryStatus.newBuilder();
sentMessage.addUnidentifiedStatus(SyncMessage.Sent.UnidentifiedDeliveryStatus.newBuilder()
.setDestinationUuid(result.getAddress().getServiceId().toString())
.setUnidentified(result.getSuccess().isUnidentified())
.build());
builder.setDestinationUuid(result.getAddress().getServiceId().toString());
if (result.getAddress().getNumber().isPresent()) {
builder.setDestinationE164(result.getAddress().getNumber().get());
}
builder.setUnidentified(result.getSuccess().isUnidentified());
sentMessage.addUnidentifiedStatus(builder.build());
}
}
if (recipient.isPresent()) {
sentMessage.setDestinationUuid(recipient.get().getServiceId().toString());
if (recipient.get().getNumber().isPresent()) {
sentMessage.setDestinationE164(recipient.get().getNumber().get());
}
}
if (dataMessage.getExpireTimer() > 0) {
@ -1110,15 +1100,9 @@ public class SignalServiceMessageSender {
SyncMessage.Builder builder = createSyncMessageBuilder();
for (ReadMessage readMessage : readMessages) {
SyncMessage.Read.Builder readBuilder = SyncMessage.Read.newBuilder().setTimestamp(readMessage.getTimestamp());
readBuilder.setSenderUuid(readMessage.getSender().getServiceId().toString());
if (readMessage.getSender().getNumber().isPresent()) {
readBuilder.setSenderE164(readMessage.getSender().getNumber().get());
}
builder.addRead(readBuilder.build());
builder.addRead(SyncMessage.Read.newBuilder()
.setTimestamp(readMessage.getTimestamp())
.setSenderUuid(readMessage.getSender().getServiceId().toString()));
}
return container.setSyncMessage(builder).build();
@ -1129,15 +1113,9 @@ public class SignalServiceMessageSender {
SyncMessage.Builder builder = createSyncMessageBuilder();
for (ViewedMessage readMessage : readMessages) {
SyncMessage.Viewed.Builder viewedBuilder = SyncMessage.Viewed.newBuilder().setTimestamp(readMessage.getTimestamp());
viewedBuilder.setSenderUuid(readMessage.getSender().getServiceId().toString());
if (readMessage.getSender().getNumber().isPresent()) {
viewedBuilder.setSenderE164(readMessage.getSender().getNumber().get());
}
builder.addViewed(viewedBuilder.build());
builder.addViewed(SyncMessage.Viewed.newBuilder()
.setTimestamp(readMessage.getTimestamp())
.setSenderUuid(readMessage.getSender().getServiceId().toString()));
}
return container.setSyncMessage(builder).build();
@ -1146,15 +1124,10 @@ public class SignalServiceMessageSender {
private Content createMultiDeviceViewOnceOpenContent(ViewOnceOpenMessage readMessage) {
Content.Builder container = Content.newBuilder();
SyncMessage.Builder builder = createSyncMessageBuilder();
SyncMessage.ViewOnceOpen.Builder viewOnceBuilder = SyncMessage.ViewOnceOpen.newBuilder().setTimestamp(readMessage.getTimestamp());
viewOnceBuilder.setSenderUuid(readMessage.getSender().getServiceId().toString());
if (readMessage.getSender().getNumber().isPresent()) {
viewOnceBuilder.setSenderE164(readMessage.getSender().getNumber().get());
}
builder.setViewOnceOpen(viewOnceBuilder.build());
builder.setViewOnceOpen(SyncMessage.ViewOnceOpen.newBuilder()
.setTimestamp(readMessage.getTimestamp())
.setSenderUuid(readMessage.getSender().getServiceId().toString()));
return container.setSyncMessage(builder).build();
}
@ -1265,9 +1238,6 @@ public class SignalServiceMessageSender {
}
if (message.getPerson().isPresent()) {
if (message.getPerson().get().getNumber().isPresent()) {
responseMessage.setThreadE164(message.getPerson().get().getNumber().get());
}
responseMessage.setThreadUuid(message.getPerson().get().getServiceId().toString());
}
@ -1355,9 +1325,6 @@ public class SignalServiceMessageSender {
verifiedMessageBuilder.setIdentityKey(ByteString.copyFrom(verifiedMessage.getIdentityKey().serialize()));
verifiedMessageBuilder.setDestinationUuid(verifiedMessage.getDestination().getServiceId().toString());
if (verifiedMessage.getDestination().getNumber().isPresent()) {
verifiedMessageBuilder.setDestinationE164(verifiedMessage.getDestination().getNumber().get());
}
switch(verifiedMessage.getVerified()) {
case DEFAULT: verifiedMessageBuilder.setState(Verified.State.DEFAULT); break;
@ -1850,13 +1817,13 @@ public class SignalServiceMessageSender {
} catch (GroupMismatchedDevicesException e) {
Log.w(TAG, "[sendGroupMessage][" + timestamp + "] Handling mismatched devices. (" + e.getMessage() + ")");
for (GroupMismatchedDevices mismatched : e.getMismatchedDevices()) {
SignalServiceAddress address = new SignalServiceAddress(ACI.parseOrThrow(mismatched.getUuid()), Optional.absent());
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(mismatched.getUuid()), Optional.absent());
handleMismatchedDevices(socket, address, mismatched.getDevices());
}
} catch (GroupStaleDevicesException e) {
Log.w(TAG, "[sendGroupMessage][" + timestamp + "] Handling stale devices. (" + e.getMessage() + ")");
for (GroupStaleDevices stale : e.getStaleDevices()) {
SignalServiceAddress address = new SignalServiceAddress(ACI.parseOrThrow(stale.getUuid()), Optional.absent());
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(stale.getUuid()), Optional.absent());
handleStaleDevices(address, stale.getDevices());
}
}
@ -1905,7 +1872,7 @@ public class SignalServiceMessageSender {
}
private List<SendMessageResult> transformGroupResponseToMessageResults(Map<SignalServiceAddress, List<Integer>> recipients, SendGroupMessageResponse response, Content content) {
Set<ACI> unregistered = response.getUnsentTargets();
Set<ServiceId> unregistered = response.getUnsentTargets();
List<SendMessageResult> failures = unregistered.stream()
.map(SignalServiceAddress::new)

Wyświetl plik

@ -46,26 +46,22 @@ import org.whispersystems.signalservice.api.messages.multidevice.ViewedMessage;
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
import org.whispersystems.signalservice.api.payments.Money;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.storage.StorageKey;
import org.whispersystems.signalservice.api.util.AttachmentPointerUtil;
import org.whispersystems.signalservice.api.util.UuidUtil;
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
import org.whispersystems.signalservice.internal.push.UnsupportedDataMessageException;
import org.whispersystems.signalservice.internal.push.UnsupportedDataMessageProtocolVersionException;
import org.whispersystems.signalservice.internal.serialize.SignalServiceAddressProtobufSerializer;
import org.whispersystems.signalservice.internal.serialize.SignalServiceMetadataProtobufSerializer;
import org.whispersystems.signalservice.internal.serialize.protos.SignalServiceContentProto;
import org.whispersystems.util.FlagUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import static org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext.Type.DELIVER;
public final class SignalServiceContent {
@ -594,8 +590,8 @@ public final class SignalServiceContent {
Map<SignalServiceAddress, Boolean> unidentifiedStatuses = new HashMap<>();
SignalServiceProtos.SyncMessage.Sent sentContent = content.getSent();
SignalServiceDataMessage dataMessage = createSignalServiceMessage(metadata, sentContent.getMessage());
Optional<SignalServiceAddress> address = SignalServiceAddress.isValidAddress(sentContent.getDestinationUuid(), sentContent.getDestinationE164())
? Optional.of(new SignalServiceAddress(ACI.parseOrThrow(sentContent.getDestinationUuid()), sentContent.getDestinationE164()))
Optional<SignalServiceAddress> address = SignalServiceAddress.isValidAddress(sentContent.getDestinationUuid())
? Optional.of(new SignalServiceAddress(ServiceId.parseOrThrow(sentContent.getDestinationUuid())))
: Optional.<SignalServiceAddress>absent();
if (!address.isPresent() && !dataMessage.getGroupContext().isPresent()) {
@ -603,8 +599,8 @@ public final class SignalServiceContent {
}
for (SignalServiceProtos.SyncMessage.Sent.UnidentifiedDeliveryStatus status : sentContent.getUnidentifiedStatusList()) {
if (SignalServiceAddress.isValidAddress(status.getDestinationUuid(), status.getDestinationE164())) {
SignalServiceAddress recipient = new SignalServiceAddress(ACI.parseOrThrow(status.getDestinationUuid()), status.getDestinationE164());
if (SignalServiceAddress.isValidAddress(status.getDestinationUuid(), null)) {
SignalServiceAddress recipient = new SignalServiceAddress(ServiceId.parseOrThrow(status.getDestinationUuid()));
unidentifiedStatuses.put(recipient, status.getUnidentified());
} else {
Log.w(TAG, "Encountered an invalid UnidentifiedDeliveryStatus in a SentTranscript! Ignoring.");
@ -627,8 +623,8 @@ public final class SignalServiceContent {
List<ReadMessage> readMessages = new LinkedList<>();
for (SignalServiceProtos.SyncMessage.Read read : content.getReadList()) {
if (SignalServiceAddress.isValidAddress(read.getSenderUuid(), read.getSenderE164())) {
SignalServiceAddress address = new SignalServiceAddress(ACI.parseOrThrow(read.getSenderUuid()), read.getSenderE164());
if (SignalServiceAddress.isValidAddress(read.getSenderUuid())) {
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(read.getSenderUuid()));
readMessages.add(new ReadMessage(address, read.getTimestamp()));
} else {
Log.w(TAG, "Encountered an invalid ReadMessage! Ignoring.");
@ -642,8 +638,8 @@ public final class SignalServiceContent {
List<ViewedMessage> viewedMessages = new LinkedList<>();
for (SignalServiceProtos.SyncMessage.Viewed viewed : content.getViewedList()) {
if (SignalServiceAddress.isValidAddress(viewed.getSenderUuid(), viewed.getSenderE164())) {
SignalServiceAddress address = new SignalServiceAddress(ACI.parseOrThrow(viewed.getSenderUuid()), viewed.getSenderE164());
if (SignalServiceAddress.isValidAddress(viewed.getSenderUuid())) {
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(viewed.getSenderUuid()));
viewedMessages.add(new ViewedMessage(address, viewed.getTimestamp()));
} else {
Log.w(TAG, "Encountered an invalid ReadMessage! Ignoring.");
@ -654,8 +650,8 @@ public final class SignalServiceContent {
}
if (content.hasViewOnceOpen()) {
if (SignalServiceAddress.isValidAddress(content.getViewOnceOpen().getSenderUuid(), content.getViewOnceOpen().getSenderE164())) {
SignalServiceAddress address = new SignalServiceAddress(ACI.parseOrThrow(content.getViewOnceOpen().getSenderUuid()), content.getViewOnceOpen().getSenderE164());
if (SignalServiceAddress.isValidAddress(content.getViewOnceOpen().getSenderUuid())) {
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(content.getViewOnceOpen().getSenderUuid()));
ViewOnceOpenMessage timerRead = new ViewOnceOpenMessage(address, content.getViewOnceOpen().getTimestamp());
return SignalServiceSyncMessage.forViewOnceOpen(timerRead);
} else {
@ -664,11 +660,11 @@ public final class SignalServiceContent {
}
if (content.hasVerified()) {
if (SignalServiceAddress.isValidAddress(content.getVerified().getDestinationUuid(), content.getVerified().getDestinationE164())) {
if (SignalServiceAddress.isValidAddress(content.getVerified().getDestinationUuid())) {
try {
SignalServiceProtos.Verified verified = content.getVerified();
SignalServiceAddress destination = new SignalServiceAddress(ACI.parseOrThrow(verified.getDestinationUuid()), verified.getDestinationE164());
IdentityKey identityKey = new IdentityKey(verified.getIdentityKey().toByteArray(), 0);
SignalServiceAddress destination = new SignalServiceAddress(ServiceId.parseOrThrow(verified.getDestinationUuid()));
IdentityKey identityKey = new IdentityKey(verified.getIdentityKey().toByteArray(), 0);
VerifiedMessage.VerifiedState verifiedState;
@ -779,7 +775,7 @@ 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(), content.getMessageRequestResponse().getThreadE164());
Optional<SignalServiceAddress> address = SignalServiceAddress.fromRaw(content.getMessageRequestResponse().getThreadUuid(), null);
if (address.isPresent()) {
responseMessage = MessageRequestResponseMessage.forIndividual(address.get(), type);
@ -899,7 +895,7 @@ public final class SignalServiceContent {
return new SignalServiceTypingMessage(action, content.getTimestamp(),
content.hasGroupId() ? Optional.of(content.getGroupId().toByteArray()) :
Optional.<byte[]>absent());
Optional.absent());
}
private static SignalServiceDataMessage.Quote createQuote(SignalServiceProtos.DataMessage content, boolean isGroupV2)
@ -915,8 +911,8 @@ public final class SignalServiceContent {
attachment.hasThumbnail() ? createAttachmentPointer(attachment.getThumbnail()) : null));
}
if (SignalServiceAddress.isValidAddress(content.getQuote().getAuthorUuid(), content.getQuote().getAuthorE164())) {
SignalServiceAddress address = new SignalServiceAddress(ACI.parseOrThrow(content.getQuote().getAuthorUuid()), content.getQuote().getAuthorE164());
if (SignalServiceAddress.isValidAddress(content.getQuote().getAuthorUuid())) {
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(content.getQuote().getAuthorUuid()));
return new SignalServiceDataMessage.Quote(content.getQuote().getId(),
address,
@ -963,7 +959,7 @@ public final class SignalServiceContent {
for (SignalServiceProtos.DataMessage.BodyRange bodyRange : bodyRanges) {
if (bodyRange.hasMentionUuid()) {
try {
mentions.add(new SignalServiceDataMessage.Mention(ACI.parseOrThrow(bodyRange.getMentionUuid()), bodyRange.getStart(), bodyRange.getLength()));
mentions.add(new SignalServiceDataMessage.Mention(ServiceId.parseOrThrow(bodyRange.getMentionUuid()), bodyRange.getStart(), bodyRange.getLength()));
} catch (IllegalArgumentException e) {
throw new InvalidMessageStructureException("Invalid body range!");
}
@ -1005,17 +1001,17 @@ public final class SignalServiceContent {
return null;
}
SignalServiceProtos.DataMessage.Reaction reaction = content.getReaction();
ACI uuid = ACI.parseOrNull(reaction.getTargetAuthorUuid());
SignalServiceProtos.DataMessage.Reaction reaction = content.getReaction();
ServiceId serviceId = ServiceId.parseOrNull(reaction.getTargetAuthorUuid());
if (uuid == null) {
if (serviceId == null) {
Log.w(TAG, "Cannot parse author UUID on reaction");
return null;
}
return new SignalServiceDataMessage.Reaction(reaction.getEmoji(),
reaction.getRemove(),
new SignalServiceAddress(uuid),
new SignalServiceAddress(serviceId),
reaction.getTargetSentTimestamp());
}
@ -1057,13 +1053,13 @@ public final class SignalServiceContent {
return null;
}
ACI aci = ACI.parseOrNull(content.getStoryContext().getAuthorUuid());
ServiceId serviceId = ServiceId.parseOrNull(content.getStoryContext().getAuthorUuid());
if (aci == null) {
if (serviceId == null) {
throw new InvalidMessageStructureException("Invalid author ACI!");
}
return new SignalServiceDataMessage.StoryContext(aci, content.getStoryContext().getSentTimestamp());
return new SignalServiceDataMessage.StoryContext(serviceId, content.getStoryContext().getSentTimestamp());
}
private static SignalServiceDataMessage.PaymentNotification createPaymentNotification(SignalServiceProtos.DataMessage.Payment content)

Wyświetl plik

@ -10,7 +10,6 @@ import org.signal.zkgroup.groups.GroupSecretParams;
import org.whispersystems.libsignal.InvalidMessageException;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.util.OptionalUtil;
@ -611,18 +610,18 @@ public class SignalServiceDataMessage {
}
public static class Mention {
private final ServiceId aci;
private final ServiceId serviceId;
private final int start;
private final int length;
public Mention(ServiceId aci, int start, int length) {
this.aci = aci;
this.start = start;
this.length = length;
public Mention(ServiceId serviceId, int start, int length) {
this.serviceId = serviceId;
this.start = start;
this.length = length;
}
public ServiceId getAci() {
return aci;
public ServiceId getServiceId() {
return serviceId;
}
public int getStart() {
@ -678,16 +677,16 @@ public class SignalServiceDataMessage {
}
public static class StoryContext {
private final ACI authorAci;
private final long sentTimestamp;
private final ServiceId authorServiceId;
private final long sentTimestamp;
public StoryContext(ACI authorAci, long sentTimestamp) {
this.authorAci = authorAci;
this.sentTimestamp = sentTimestamp;
public StoryContext(ServiceId authorServiceId, long sentTimestamp) {
this.authorServiceId = authorServiceId;
this.sentTimestamp = sentTimestamp;
}
public ACI getAuthorAci() {
return authorAci;
public ServiceId getAuthorServiceId() {
return authorServiceId;
}
public long getSentTimestamp() {

Wyświetl plik

@ -14,7 +14,7 @@ import org.whispersystems.libsignal.InvalidMessageException;
import org.whispersystems.libsignal.logging.Log;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
import org.whispersystems.signalservice.internal.util.Util;
@ -45,7 +45,7 @@ public class DeviceContactsInputStream extends ChunkedInputStream {
throw new IOException("Missing contact address!");
}
SignalServiceAddress address = new SignalServiceAddress(ACI.parseOrThrow(details.getUuid()), details.getNumber());
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(details.getUuid()), details.getNumber());
Optional<String> name = Optional.fromNullable(details.getName());
Optional<SignalServiceAttachmentStream> avatar = Optional.absent();
Optional<String> color = details.hasColor() ? Optional.of(details.getColor()) : Optional.<String>absent();
@ -66,12 +66,11 @@ public class DeviceContactsInputStream extends ChunkedInputStream {
if (details.hasVerified()) {
try {
if (!SignalServiceAddress.isValidAddress(details.getVerified().getDestinationUuid(), details.getVerified().getDestinationE164())) {
if (!SignalServiceAddress.isValidAddress(details.getVerified().getDestinationUuid(), null)) {
throw new InvalidMessageException("Missing Verified address!");
}
IdentityKey identityKey = new IdentityKey(details.getVerified().getIdentityKey().toByteArray(), 0);
SignalServiceAddress destination = new SignalServiceAddress(ACI.parseOrThrow(details.getVerified().getDestinationUuid()),
details.getVerified().getDestinationE164());
SignalServiceAddress destination = new SignalServiceAddress(ServiceId.parseOrThrow(details.getVerified().getDestinationUuid()));
VerifiedMessage.VerifiedState state;

Wyświetl plik

@ -72,10 +72,6 @@ public class DeviceContactsOutputStream extends ChunkedOutputStream {
.setDestinationUuid(contact.getVerified().get().getDestination().getServiceId().toString())
.setState(state);
if (contact.getVerified().get().getDestination().getNumber().isPresent()) {
verifiedBuilder.setDestinationE164(contact.getVerified().get().getDestination().getNumber().get());
}
contactDetails.setVerified(verifiedBuilder.build());
}

Wyświetl plik

@ -12,6 +12,7 @@ import org.signal.zkgroup.InvalidInputException;
import org.signal.zkgroup.profiles.ProfileKeyCredentialResponse;
import org.whispersystems.libsignal.logging.Log;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.internal.util.JsonUtil;
import java.math.BigDecimal;
@ -55,9 +56,9 @@ public class SignalServiceProfile {
private Capabilities capabilities;
@JsonProperty
@JsonSerialize(using = JsonUtil.AciSerializer.class)
@JsonDeserialize(using = JsonUtil.AciDeserializer.class)
private ACI uuid;
@JsonSerialize(using = JsonUtil.ServiceIdSerializer.class)
@JsonDeserialize(using = JsonUtil.ServiceIdDeserializer.class)
private ServiceId uuid;
@JsonProperty
private byte[] credential;
@ -110,7 +111,7 @@ public class SignalServiceProfile {
return badges;
}
public ACI getAci() {
public ServiceId getServiceId() {
return uuid;
}

Wyświetl plik

@ -12,8 +12,6 @@ import java.util.UUID;
*/
public final class ACI extends ServiceId {
public static final ACI UNKNOWN = ACI.from(UuidUtil.UNKNOWN_UUID);
public static ACI from(UUID uuid) {
return new ACI(uuid);
}

Wyświetl plik

@ -66,13 +66,17 @@ public class SignalServiceAddress {
return this.serviceId.equals(other.serviceId);
}
public static boolean isValidAddress(String rawUuid) {
return isValidAddress(rawUuid, null);
}
public static boolean isValidAddress(String rawUuid, String e164) {
return UuidUtil.parseOrNull(rawUuid) != null;
}
public static Optional<SignalServiceAddress> fromRaw(String rawUuid, String e164) {
if (isValidAddress(rawUuid, e164)) {
return Optional.of(new SignalServiceAddress(ACI.parseOrThrow(rawUuid), e164));
return Optional.of(new SignalServiceAddress(ServiceId.parseOrThrow(rawUuid), e164));
} else {
return Optional.absent();
}

Wyświetl plik

@ -6,7 +6,7 @@ import com.google.protobuf.InvalidProtocolBufferException;
import org.whispersystems.libsignal.logging.Log;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.payments.PaymentsConstants;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.util.OptionalUtil;
import org.whispersystems.signalservice.api.util.ProtoUtil;
@ -315,7 +315,7 @@ public final class SignalAccountRecord implements SignalRecord {
static PinnedConversation fromRemote(AccountRecord.PinnedConversation remote) {
if (remote.hasContact()) {
return forContact(new SignalServiceAddress(ACI.parseOrThrow(remote.getContact().getUuid()), remote.getContact().getE164()));
return forContact(new SignalServiceAddress(ServiceId.parseOrThrow(remote.getContact().getUuid()), remote.getContact().getE164()));
} else if (!remote.getLegacyGroupId().isEmpty()) {
return forGroupV1(remote.getLegacyGroupId().toByteArray());
} else if (!remote.getGroupMasterKey().isEmpty()) {

Wyświetl plik

@ -6,6 +6,7 @@ import com.google.protobuf.InvalidProtocolBufferException;
import org.whispersystems.libsignal.logging.Log;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.util.OptionalUtil;
import org.whispersystems.signalservice.api.util.ProtoUtil;
@ -37,7 +38,7 @@ public final class SignalContactRecord implements SignalRecord {
this.proto = proto;
this.hasUnknownFields = ProtoUtil.hasUnknownFields(proto);
this.address = new SignalServiceAddress(ACI.parseOrUnknown(proto.getServiceUuid()), proto.getServiceE164());
this.address = new SignalServiceAddress(ServiceId.parseOrUnknown(proto.getServiceUuid()), proto.getServiceE164());
this.givenName = OptionalUtil.absentIfEmpty(proto.getGivenName());
this.familyName = OptionalUtil.absentIfEmpty(proto.getFamilyName());
this.profileKey = OptionalUtil.absentIfEmpty(proto.getProfileKey());

Wyświetl plik

@ -2,8 +2,10 @@ package org.whispersystems.signalservice.internal.push;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.whispersystems.libsignal.logging.Log;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.util.UuidUtil;
import java.util.HashSet;
@ -12,21 +14,25 @@ import java.util.UUID;
public class SendGroupMessageResponse {
private static final String TAG = SendGroupMessageResponse.class.getSimpleName();
@JsonProperty
private String[] uuids404;
public SendGroupMessageResponse() {}
public Set<ACI> getUnsentTargets() {
Set<ACI> acis = new HashSet<>(uuids404.length);
public Set<ServiceId> getUnsentTargets() {
Set<ServiceId> serviceIds = new HashSet<>(uuids404.length);
for (String raw : uuids404) {
ACI parsed = ACI.parseOrNull(raw);
ServiceId parsed = ServiceId.parseOrNull(raw);
if (parsed != null) {
acis.add(parsed);
serviceIds.add(parsed);
} else {
Log.w(TAG, "Failed to parse ServiceId!");
}
}
return acis;
return serviceIds;
}
}

Wyświetl plik

@ -22,6 +22,7 @@ import org.whispersystems.libsignal.IdentityKey;
import org.whispersystems.libsignal.InvalidKeyException;
import org.whispersystems.libsignal.logging.Log;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.exceptions.MalformedResponseException;
import org.whispersystems.signalservice.api.util.UuidUtil;
import org.whispersystems.util.Base64;
@ -131,4 +132,20 @@ public class JsonUtil {
return ACI.parseOrNull(p.getValueAsString());
}
}
public static class ServiceIdSerializer extends JsonSerializer<ServiceId> {
@Override
public void serialize(ServiceId value, JsonGenerator gen, SerializerProvider serializers)
throws IOException
{
gen.writeString(value.toString());
}
}
public static class ServiceIdDeserializer extends JsonDeserializer<ServiceId> {
@Override
public ServiceId deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
return ServiceId.parseOrNull(p.getValueAsString());
}
}
}

Wyświetl plik

@ -144,7 +144,7 @@ message DataMessage {
}
optional uint64 id = 1;
optional string authorE164 = 2;
reserved /*authorE164*/ 2;
optional string authorUuid = 5;
optional string text = 3;
repeated QuotedAttachment attachments = 4;
@ -237,7 +237,7 @@ message DataMessage {
message Reaction {
optional string emoji = 1;
optional bool remove = 2;
reserved /* targetAuthorE164 */ 3; // removed
reserved /*targetAuthorE164*/ 3;
optional string targetAuthorUuid = 4;
optional uint64 targetSentTimestamp = 5;
}
@ -363,7 +363,7 @@ message Verified {
UNVERIFIED = 2;
}
optional string destinationE164 = 1;
reserved /*destinationE164*/ 1;
optional string destinationUuid = 5;
optional bytes identityKey = 2;
optional State state = 3;
@ -373,12 +373,12 @@ message Verified {
message SyncMessage {
message Sent {
message UnidentifiedDeliveryStatus {
optional string destinationE164 = 1;
reserved /*destinationE164*/ 1;
optional string destinationUuid = 3;
optional bool unidentified = 2;
}
optional string destinationE164 = 1;
reserved /*destinationE164*/ 1;
optional string destinationUuid = 7;
optional uint64 timestamp = 2;
optional DataMessage message = 3;
@ -417,22 +417,22 @@ message SyncMessage {
}
message Read {
optional string senderE164 = 1;
reserved /*senderE164*/ 1;
optional string senderUuid = 3;
optional uint64 timestamp = 2;
}
message Viewed {
optional string senderE164 = 1;
reserved /*senderE164*/ 1;
optional string senderUuid = 3;
optional uint64 timestamp = 2;
optional uint64 timestamp = 2;
}
message Configuration {
optional bool readReceipts = 1;
optional bool unidentifiedDeliveryIndicators = 2;
optional bool typingIndicators = 3;
reserved /* linkPreviews */ 4; // removed
reserved /* linkPreviews */ 4;
optional uint32 provisioningVersion = 5;
optional bool linkPreviews = 6;
}
@ -449,7 +449,7 @@ message SyncMessage {
}
message ViewOnceOpen {
optional string senderE164 = 1;
reserved /*senderE164*/ 1;
optional string senderUuid = 3;
optional uint64 timestamp = 2;
}
@ -483,7 +483,7 @@ message SyncMessage {
BLOCK_AND_DELETE = 4;
}
optional string threadE164 = 1;
reserved /*threadE164*/ 1;
optional string threadUuid = 2;
optional bytes groupId = 3;
optional Type type = 4;

Wyświetl plik

@ -7,7 +7,7 @@ import org.whispersystems.libsignal.IdentityKey;
import org.whispersystems.libsignal.ecc.Curve;
import org.whispersystems.libsignal.ecc.ECKeyPair;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.internal.util.Util;
@ -17,7 +17,6 @@ import java.io.IOException;
import java.util.UUID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class DeviceContactsInputStreamTest {
@ -25,8 +24,8 @@ public class DeviceContactsInputStreamTest {
public void read() throws IOException, InvalidInputException {
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
DeviceContactsOutputStream output = new DeviceContactsOutputStream(byteArrayOut);
SignalServiceAddress addressFirst = new SignalServiceAddress(ACI.from(UUID.randomUUID()), "+1404555555");
SignalServiceAddress addressSecond = new SignalServiceAddress(ACI.from(UUID.randomUUID()), "+1444555555");
SignalServiceAddress addressFirst = new SignalServiceAddress(ServiceId.from(UUID.randomUUID()), "+1404555555");
SignalServiceAddress addressSecond = new SignalServiceAddress(ServiceId.from(UUID.randomUUID()), "+1444555555");
DeviceContact first = new DeviceContact(
addressFirst,

Wyświetl plik

@ -2,24 +2,24 @@ package org.whispersystems.signalservice.api.storage;
import org.junit.Test;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.util.UuidUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
public class SignalContactRecordTest {
private static final ACI ACI_A = ACI.parseOrThrow("ebef429e-695e-4f51-bcc4-526a60ac68c7");
private static final String E164_A = "+16108675309";
private static final ServiceId SID_A = ServiceId.parseOrThrow("ebef429e-695e-4f51-bcc4-526a60ac68c7");
private static final String E164_A = "+16108675309";
@Test
public void contacts_with_same_identity_key_contents_are_equal() {
byte[] profileKey = new byte[32];
byte[] profileKeyCopy = profileKey.clone();
SignalContactRecord a = contactBuilder(1, ACI_A, E164_A, "a").setIdentityKey(profileKey).build();
SignalContactRecord b = contactBuilder(1, ACI_A, E164_A, "a").setIdentityKey(profileKeyCopy).build();
SignalContactRecord a = contactBuilder(1, SID_A, E164_A, "a").setIdentityKey(profileKey).build();
SignalContactRecord b = contactBuilder(1, SID_A, E164_A, "a").setIdentityKey(profileKeyCopy).build();
assertEquals(a, b);
assertEquals(a.hashCode(), b.hashCode());
@ -31,8 +31,8 @@ public class SignalContactRecordTest {
byte[] profileKeyCopy = profileKey.clone();
profileKeyCopy[0] = 1;
SignalContactRecord a = contactBuilder(1, ACI_A, E164_A, "a").setIdentityKey(profileKey).build();
SignalContactRecord b = contactBuilder(1, ACI_A, E164_A, "a").setIdentityKey(profileKeyCopy).build();
SignalContactRecord a = contactBuilder(1, SID_A, E164_A, "a").setIdentityKey(profileKey).build();
SignalContactRecord b = contactBuilder(1, SID_A, E164_A, "a").setIdentityKey(profileKeyCopy).build();
assertNotEquals(a, b);
assertNotEquals(a.hashCode(), b.hashCode());
@ -48,11 +48,11 @@ public class SignalContactRecordTest {
}
private static SignalContactRecord.Builder contactBuilder(int key,
ACI aci,
ServiceId serviceId,
String e164,
String givenName)
{
return new SignalContactRecord.Builder(byteArray(key), new SignalServiceAddress(aci, e164), null)
return new SignalContactRecord.Builder(byteArray(key), new SignalServiceAddress(serviceId, e164), null)
.setGivenName(givenName);
}
}