Remove E164s most places and prefer ServiceId more places.\

This commit is contained in:
Greyson Parrelli
2022-02-23 17:28:11 -05:00
committed by Alex Hart
parent d6b6884c69
commit 935dd7de45
50 changed files with 296 additions and 304 deletions

View File

@@ -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)) {

View File

@@ -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();
}