Expand account consistency checks.
This commit is contained in:
parent
9762899272
commit
4bcd1df4f8
2 changed files with 38 additions and 6 deletions
|
@ -56,19 +56,34 @@ class AccountConsistencyWorkerJob private constructor(parameters: Parameters) :
|
|||
return
|
||||
}
|
||||
|
||||
val profile: SignalServiceProfile = ProfileUtil.retrieveProfileSync(context, Recipient.self(), SignalServiceProfile.RequestType.PROFILE, false).profile
|
||||
val encodedPublicKey = Base64.encodeWithPadding(SignalStore.account().aciIdentityKey.publicKey.serialize())
|
||||
val aciProfile: SignalServiceProfile = ProfileUtil.retrieveProfileSync(context, Recipient.self(), SignalServiceProfile.RequestType.PROFILE, false).profile
|
||||
val encodedAciPublicKey = Base64.encodeWithPadding(SignalStore.account().aciIdentityKey.publicKey.serialize())
|
||||
|
||||
if (profile.identityKey != encodedPublicKey) {
|
||||
Log.w(TAG, "Identity key on profile differed from the one we have locally! Marking ourselves unregistered.")
|
||||
if (aciProfile.identityKey != encodedAciPublicKey) {
|
||||
Log.w(TAG, "ACI identity key on profile differed from the one we have locally! Marking ourselves unregistered.")
|
||||
|
||||
SignalStore.account().setRegistered(false)
|
||||
SignalStore.registrationValues().clearRegistrationComplete()
|
||||
SignalStore.registrationValues().clearHasUploadedProfile()
|
||||
} else {
|
||||
Log.i(TAG, "Everything matched.")
|
||||
|
||||
SignalStore.misc().lastConsistencyCheckTime = System.currentTimeMillis()
|
||||
return
|
||||
}
|
||||
|
||||
val pniProfile: SignalServiceProfile = ProfileUtil.retrieveProfileSync(SignalStore.account().pni!!, SignalServiceProfile.RequestType.PROFILE).profile
|
||||
val encodedPniPublicKey = Base64.encodeWithPadding(SignalStore.account().pniIdentityKey.publicKey.serialize())
|
||||
|
||||
if (pniProfile.identityKey != encodedPniPublicKey) {
|
||||
Log.w(TAG, "PNI identity key on profile differed from the one we have locally!")
|
||||
|
||||
SignalStore.account().setRegistered(false)
|
||||
SignalStore.registrationValues().clearRegistrationComplete()
|
||||
SignalStore.registrationValues().clearHasUploadedProfile()
|
||||
return
|
||||
}
|
||||
|
||||
Log.i(TAG, "Everything matched.")
|
||||
|
||||
SignalStore.misc().lastConsistencyCheckTime = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue