Fallback to profile fetches for unlisted contacts.

This commit is contained in:
Greyson Parrelli
2020-09-22 16:24:13 -04:00
parent a05f74d302
commit a2c2ab428a
11 changed files with 175 additions and 42 deletions

View File

@@ -5,11 +5,13 @@ import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import androidx.navigation.ActionOnlyNavDirections;
import org.signal.zkgroup.VerificationFailedException;
import org.signal.zkgroup.profiles.ProfileKey;
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
import org.thoughtcrime.securesms.database.RecipientDatabase;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.recipients.Recipient;
@@ -56,6 +58,8 @@ public final class ProfileUtil {
} catch (ExecutionException e) {
if (e.getCause() instanceof PushNetworkException) {
throw (PushNetworkException) e.getCause();
} else if (e.getCause() instanceof NotFoundException) {
throw (NotFoundException) e.getCause();
} else {
throw new IOException(e);
}
@@ -68,7 +72,7 @@ public final class ProfileUtil {
@NonNull Recipient recipient,
@NonNull SignalServiceProfile.RequestType requestType)
{
SignalServiceAddress address = RecipientUtil.toSignalServiceAddressBestEffort(context, recipient);
SignalServiceAddress address = toSignalServiceAddress(context, recipient);
Optional<UnidentifiedAccess> unidentifiedAccess = getUnidentifiedAccess(context, recipient);
Optional<ProfileKey> profileKey = ProfileKeyUtil.profileKeyOptional(recipient.getProfileKey());
@@ -131,4 +135,12 @@ public final class ProfileUtil {
return Optional.absent();
}
private static @NonNull SignalServiceAddress toSignalServiceAddress(@NonNull Context context, @NonNull Recipient recipient) {
if (recipient.getRegistered() == RecipientDatabase.RegisteredState.NOT_REGISTERED) {
return new SignalServiceAddress(recipient.getUuid().orNull(), recipient.getE164().orNull());
} else {
return RecipientUtil.toSignalServiceAddressBestEffort(context, recipient);
}
}
}