mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 12:38:33 +00:00
Expand account consistency checks.
This commit is contained in:
@@ -56,19 +56,34 @@ class AccountConsistencyWorkerJob private constructor(parameters: Parameters) :
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val profile: SignalServiceProfile = ProfileUtil.retrieveProfileSync(context, Recipient.self(), SignalServiceProfile.RequestType.PROFILE, false).profile
|
val aciProfile: SignalServiceProfile = ProfileUtil.retrieveProfileSync(context, Recipient.self(), SignalServiceProfile.RequestType.PROFILE, false).profile
|
||||||
val encodedPublicKey = Base64.encodeWithPadding(SignalStore.account().aciIdentityKey.publicKey.serialize())
|
val encodedAciPublicKey = Base64.encodeWithPadding(SignalStore.account().aciIdentityKey.publicKey.serialize())
|
||||||
|
|
||||||
if (profile.identityKey != encodedPublicKey) {
|
if (aciProfile.identityKey != encodedAciPublicKey) {
|
||||||
Log.w(TAG, "Identity key on profile differed from the one we have locally! Marking ourselves unregistered.")
|
Log.w(TAG, "ACI identity key on profile differed from the one we have locally! Marking ourselves unregistered.")
|
||||||
|
|
||||||
SignalStore.account().setRegistered(false)
|
SignalStore.account().setRegistered(false)
|
||||||
SignalStore.registrationValues().clearRegistrationComplete()
|
SignalStore.registrationValues().clearRegistrationComplete()
|
||||||
SignalStore.registrationValues().clearHasUploadedProfile()
|
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()
|
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.AvatarUploadParams;
|
||||||
import org.whispersystems.signalservice.api.profiles.ProfileAndCredential;
|
import org.whispersystems.signalservice.api.profiles.ProfileAndCredential;
|
||||||
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
|
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.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.services.ProfileService;
|
import org.whispersystems.signalservice.api.services.ProfileService;
|
||||||
import org.whispersystems.signalservice.api.util.StreamDetails;
|
import org.whispersystems.signalservice.api.util.StreamDetails;
|
||||||
@@ -108,6 +109,22 @@ public final class ProfileUtil {
|
|||||||
return new ProfileService.ProfileResponseProcessor(response.second()).getResultOrThrow();
|
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,
|
public static Single<Pair<Recipient, ServiceResponse<ProfileAndCredential>>> retrieveProfile(@NonNull Context context,
|
||||||
@NonNull Recipient recipient,
|
@NonNull Recipient recipient,
|
||||||
@NonNull SignalServiceProfile.RequestType requestType)
|
@NonNull SignalServiceProfile.RequestType requestType)
|
||||||
|
|||||||
Reference in New Issue
Block a user