Expand account consistency checks.

This commit is contained in:
Greyson Parrelli
2024-04-17 16:58:44 -04:00
parent 9762899272
commit 4bcd1df4f8
2 changed files with 38 additions and 6 deletions

View File

@@ -43,6 +43,7 @@ import org.whispersystems.signalservice.api.crypto.UnidentifiedAccessPair;
import org.whispersystems.signalservice.api.profiles.AvatarUploadParams;
import org.whispersystems.signalservice.api.profiles.ProfileAndCredential;
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.services.ProfileService;
import org.whispersystems.signalservice.api.util.StreamDetails;
@@ -108,6 +109,22 @@ public final class ProfileUtil {
return new ProfileService.ProfileResponseProcessor(response.second()).getResultOrThrow();
}
@WorkerThread
public static @NonNull ProfileAndCredential retrieveProfileSync(@NonNull ServiceId.PNI pni,
@NonNull SignalServiceProfile.RequestType requestType)
throws IOException
{
ProfileService profileService = ApplicationDependencies.getProfileService();
ServiceResponse<ProfileAndCredential> response = Single
.fromCallable(() -> new SignalServiceAddress(pni))
.flatMap(address -> profileService.getProfile(address, Optional.empty(), Optional.empty(), requestType, Locale.getDefault()))
.onErrorReturn(t -> ServiceResponse.forUnknownError(t))
.blockingGet();
return new ProfileService.ProfileResponseProcessor(response).getResultOrThrow();
}
public static Single<Pair<Recipient, ServiceResponse<ProfileAndCredential>>> retrieveProfile(@NonNull Context context,
@NonNull Recipient recipient,
@NonNull SignalServiceProfile.RequestType requestType)